ponder-lab / Rejuvenate-Logging-Levels

An Eclipse plug-in research prototype for automatically rejuvenating log statement levels using degree of interest
Eclipse Public License 2.0
2 stars 3 forks source link

NPE while processing californium #172

Closed khatchad closed 5 years ago

khatchad commented 5 years ago
!ENTRY edu.cuny.hunter.log.evaluation 4 0 2019-04-08 18:18:06.745
!MESSAGE Encountered exception during evaluation
!STACK 0
java.lang.NullPointerException
        at org.eclipse.jdt.internal.corext.dom.ASTNodes.getParent(ASTNodes.java:1036)
        at edu.cuny.hunter.log.core.analysis.LogInvocation.getEnclosingCompilationUnit(LogInvocation.java:160)
        at edu.cuny.hunter.log.core.analysis.LogAnalyzer.checkCodeModification(LogAnalyzer.java:370)
        at edu.cuny.hunter.log.core.analysis.LogAnalyzer.analyzeLogInvs(LogAnalyzer.java:87)
        at edu.cuny.hunter.log.core.analysis.LogAnalyzer.analyze(LogAnalyzer.java:76)
        at edu.cuny.hunter.log.core.refactorings.LogRejuvenatingProcessor.checkFinalConditions(LogRejuvenatingProcessor.java:245)
        at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225)
        at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:165)
        at edu.cuny.hunter.log.evaluation.handlers.EvaluationHandler.lambda$0(EvaluationHandler.java:138)
        at org.eclipse.core.runtime.jobs.Job$1.run(Job.java:164)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

https://github.com/eclipse/californium.git 0dd6db579be90c514dd765027ec55ed7a4668337

Seems like it's occurring in the subproject "scandium".

khatchad commented 5 years ago

Looks like the enclosing type declaration is returning null here: https://github.com/ponder-lab/Logging-Level-Evolution-Plugin/blob/a84aa094dbd00ade8867d3416cf04702c911d496/edu.cuny.hunter.log.core/src/edu/cuny/hunter/log/core/analysis/LogInvocation.java#L160

That is, this.getEnclosingTypeDeclaration() returns null.

khatchad commented 5 years ago

Seems like it's also happening in selenium.

yiming-tang-cs commented 5 years ago

One failing case is:

https://github.com/eclipse/californium/blob/9f6f90e53668ea5d5f8946f9f952d3f3892e24de/scandium-core/src/main/java/org/eclipse/californium/scandium/dtls/CompressionMethod.java#L68-L79

It looks like the log invocation is in an enum.

khatchad commented 5 years ago

Hm, an enum is a type. Shouldn't be a problem.

khatchad commented 5 years ago

Actually, they are separate.

yiming-tang-cs commented 5 years ago

I am checking its AST tree.

khatchad commented 5 years ago

It's in the docs:

https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/ASTNode.html#ENUM_DECLARATION

https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/ASTNode.html#ANNOTATION_TYPE_DECLARATION

https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/ASTNode.html#TYPE_DECLARATION

They are separate.

yiming-tang-cs commented 5 years ago

I see. That's why the tool gets null for type declaration.

yiming-tang-cs commented 5 years ago

This issue is fixed by @khatchad through https://github.com/ponder-lab/Logging-Level-Evolution-Plugin/commit/6db0c7ae266282be6830af245ebf5f0df40292da

The new NPE of type declaration is: https://github.com/ponder-lab/Logging-Level-Evolution-Plugin/issues/174