java.lang.IllegalStateException: Expected to have a deferred type but got Throwable

285 views
Skip to first unread message

frank...@gmail.com

unread,
Jun 3, 2016, 4:56:39 AM6/3/16
to SonarQube
Hi in a jenkins job I am  using  SonarQube 5.5 with the  Java Plugin 5.14 and the logfile for an analysis shows severall errors like this:
[INFO] Java Main Files AST scan...
[INFO] 277 source files to be analyzed
[INFO] 41/277 files analyzed, current file: /opt/jenkins/home/jobs/ESF-Bund Nightly Build/workspace/esfbund-logic/src/main/java/com/pass/project/esfbund/logic/counterfoil/statuslight/rules/Rule13Sums.java
[INFO] 122/277 files analyzed, current file: /opt/jenkins/home/jobs/ESF-Bund Nightly Build/workspace/esfbund-logic/src/main/java/com/pass/project/esfbund/logic/paymentapplication/PaymentApplicationService.java
[ERROR] Unable to create symbol table for : /opt/jenkins/home/jobs/ESF-Bund Nightly Build/workspace/esfbund-logic/src/main/java/com/pass/project/esfbund/logic/report/createservices/AppendixXiiService.java
java.lang.IllegalStateException: Expected to have a deferred type but got Throwable
 at com
.google.common.base.Preconditions.checkState(Preconditions.java:145) ~[sonar-plugin-api-deps6364027070355576515jar:na]
 at org
.sonar.java.model.AbstractTypedTree.setInferedType(AbstractTypedTree.java:60) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.resolve.TypeAndReferenceSolver.setInferedType(TypeAndReferenceSolver.java:232) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.resolve.TypeAndReferenceSolver.inferArgumentTypes(TypeAndReferenceSolver.java:654) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.resolve.TypeAndReferenceSolver.visitMethodInvocation(TypeAndReferenceSolver.java:223) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.model.expression.MethodInvocationTreeImpl.accept(MethodInvocationTreeImpl.java:82) ~[java-frontend-3.14.jar:na]
 at org
.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-3.14.jar:na]
 at org
.sonar.plugins.java.api.tree.BaseTreeVisitor.visitReturnStatement(BaseTreeVisitor.java:173) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.resolve.TypeAndReferenceSolver.visitReturnStatement(TypeAndReferenceSolver.java:457) ~[java-frontend-3.14.jar:na]
 at org
.sonar.java.model.statement.ReturnStatementTreeImpl.accept(ReturnStatementTreeImpl.java:69) ~[java-frontend-3.14.jar:na]



Nevertheless, the analysis claims to be successful and it will generate analysis report on the server

[INFO] Analysis report generated in 1839ms, dir size=12 MB
[INFO] Analysis reports compressed in 2536ms, zip size=4 MB
[INFO] Analysis report uploaded in 2392ms
[INFO] ANALYSIS SUCCESSFUL, you can browse https://sonar.XXXXX


But the jenkins-job  will report its state as UNSTABLE.

What is the problem.

Nicolas Peru

unread,
Jun 3, 2016, 5:04:04 AM6/3/16
to frank...@gmail.com, SonarQube
Hi, 

This seems to be an issue with inference : would you be able to share the code of the failed ifle ?  

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/f94be8e7-4125-45ee-97d7-2ee6ae31fafd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com

Nicolas Peru

unread,
Jun 3, 2016, 5:05:30 AM6/3/16
to frank...@gmail.com, SonarQube
Hi, sorry I hit the sent button a bit too fast : 

would you be able to share the code of the failed file ?  ie:  /opt/jenkins/home/jobs/ESF-Bund Nightly Build/workspace/esfbund-logic/src/main/java/com/pass/project/esfbund/logic/report/createservices/AppendixXiiService.java

you can send it privately to me if you prefer. 

Cheers, 

frank...@gmail.com

unread,
Jun 3, 2016, 11:42:19 AM6/3/16
to SonarQube, frank...@gmail.com
I would prefer to send you the file privately.

frank...@gmail.com

unread,
Jun 13, 2016, 12:58:53 PM6/13/16
to SonarQube, frank...@gmail.com
Hi,

on Friday 3rd June, I did send you a source file and the complete log file via e-mail. 
However, I did send it form my company e-mail and not from the google account, I am using here.
So  I was wondering whether you did receive the e-mail.

Sincerely

Frank Graf

Nicolas Peru

unread,
Jun 14, 2016, 2:06:33 AM6/14/16
to frank...@gmail.com, SonarQube
Hi Frank, 

Yes I did receive your source code. But this mailing list is community support and we do it on a best effort basis. So I'll handle it at one point... but it might takes time. 

Cheers, 


For more options, visit https://groups.google.com/d/optout.

bauer...@gmail.com

unread,
Jun 21, 2016, 11:55:38 AM6/21/16
to SonarQube, frank...@gmail.com
I got the same issue here since Version 5.6 as well. Is there a human understandable description on what this error means how I can interpret this error and correct my code?


java.lang.IllegalStateException: Expected to have a deferred type but got LoginAttempt


I my case I guess the issue is in this part of the code but I have no idea where and why?


Enter code here...    private static List<GrantedAuthority> filterAddAuthorities(User dbUser, boolean tfaCodeValid) {

        if (CollectionUtils.isEmpty(dbUser.getRoles()))
            return null;

        List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
        if (!BooleanUtils.isTrue(dbUser.getForceTFA()) || tfaCodeValid) {
            for (Role item : dbUser.getRoles()) {
                grantedAuthorities.add(item::getName);
            }
            grantedAuthorities.add(() -> Role.ROLES.ROLE_AUTHENTICATED);
        } else {
            grantedAuthorities.add(() -> Role.ROLES.ROLE_PREAUTH);
        }
        return grantedAuthorities;
    }

    private void saveLoginAttempt(User user, boolean successful, String ipAddress) throws InvalidCredentialsException {
        Set<LoginAttempt> loginAttempts = CollectionUtils.isEmpty(user.getLoginAttempts()) ? new HashSet<>() :
                user.getLoginAttempts();

        if (loginAttempts.size() >= LOGIN_HISTORY_SIZE)
            user.getLoginAttempts()
                    .stream()
                    .max(Comparator.comparing(LoginAttempt::getTimestamp).reversed())
                    .ifPresent(item -> {
                        loginAttemptDAO.delete(item);
                        loginAttempts.remove(item);
                    });

        LoginAttempt loginAttempt = new LoginAttempt(Calendar.getInstance(), successful, ipAddress);
        loginAttemptDAO.update(loginAttempt);
        loginAttempts.add(loginAttempt);
        user.setLoginAttempts(loginAttempts);

        if (loginAttempts.stream()
                .filter(la -> la.getSuccessful() != Boolean.TRUE)
                .count() >= LOCK_AFTER_LOGIN_ATTEMPTS)
            user.setForceCaptcha(true);
    }


    private boolean checkLoginIntervall(User user) {
        if (CollectionUtils.isEmpty(user.getLoginAttempts()))
            return true;

        LoginAttempt lastNegativeLoginAttempt = user.getLoginAttempts()
                .stream()
                .filter(la -> la.getSuccessful() != Boolean.TRUE)
                .max(Comparator.comparing(LoginAttempt::getTimestamp))
                .orElse(null);
        if (lastNegativeLoginAttempt == null)
            return true;

        LocalDateTime triggeredTime = LocalDateTime.ofInstant(lastNegativeLoginAttempt.getTimestamp().toInstant(), ZoneId
                .systemDefault());
        LocalDateTime thresholdTime = LocalDateTime.now().minus(MIN_LOGIN_INTERVAL_MILLISECONDS, ChronoUnit.MILLIS);
        return !thresholdTime.isBefore(triggeredTime);
    }




regards,
Vadim

Nicolas Peru

unread,
Jun 24, 2016, 3:34:21 AM6/24/16
to bauer...@gmail.com, SonarQube, frank...@gmail.com
Hi all, 
Sorry for the delay of answer.
Thanks a lot for the reproducers. 
This was a but in the inference resolution of semantic analysis.
Investigating this, it should be fixed in the upcoming 4.0 version as a lot of work has been done on the semantic analysis. We are about to release an RC and open a feedback period, I'll update this thread with a link to the RC so you can test it. 
HTH,
Cheers, 


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nicolas Peru

unread,
Jun 29, 2016, 2:29:52 AM6/29/16
to bauer...@gmail.com, SonarQube, frank...@gmail.com
Hello, 

The feedback period is open, please have a look at the RC and tell us if you still encounter the issue : https://groups.google.com/forum/#!topic/sonarqube/hfOPZtakoeA 

Cheers, 
Reply all
Reply to author
Forward
0 new messages