Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Boot Hint Decorators not working when app ObjectMapper configured with NON_DEFAULT inclusion #80

Closed
philsttr opened this issue Sep 26, 2018 · 4 comments
Milestone

Comments

@philsttr
Copy link

I'm using a brand new STS4 4.0.0.RELEASE installation with Java 11 support

I have a new app using Spring Boot 2.1.0.M4 with spring boot actuator with JMX endpoints enabled.

When I start the spring boot app from eclipse (either run or debug), the app starts, but the Live Boot Hint Decorators do not work.

I enabled STS Language Server Debug Console for Spring Boot and saw the below exceptions in the debug console log when I start my app.

[Timer-0] INFO org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp - Creating JMX connector: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc0AAtVbmljYXN0UmVmMgAACWxvY2FsaG9zdAAAw9vPae4gPiprxZw1v24AAAFmE49ZWYACAHg=
[Timer-0] INFO org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp - Created JMX connector: javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc0AAtVbmljYXN0UmVmMgAACWxvY2FsaG9zdAAAw9vPae4gPiprxZw1v24AAAFmE49ZWYACAHg=
[Timer-0] ERROR org.springframework.ide.vscode.commons.util.Log - Error
org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]
	at org.json.JSONTokener.syntaxError(JSONTokener.java:451)
	at org.json.JSONArray.<init>(JSONArray.java:108)
	at org.json.JSONArray.<init>(JSONArray.java:147)
	at org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel$Boot15Parser.parse(LiveBeansModel.java:77)
	at org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel.parse(LiveBeansModel.java:171)
	at org.springframework.ide.vscode.commons.boot.app.cli.AbstractSpringBootApp.lambda$getBeans$2(AbstractSpringBootApp.java:225)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.boot.app.cli.AbstractSpringBootApp.getBeans(AbstractSpringBootApp.java:217)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649.CGLIB$getBeans$17(<generated>)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649$$FastClassByCGLIB$$f5a823d1.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.lambda$null$0(MemoizingProxy.java:73)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$Result.<init>(MemoizingProxy.java:40)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.lambda$intercept$1(MemoizingProxy.java:71)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.intercept(MemoizingProxy.java:71)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649.getBeans(<generated>)
	at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.lambda$null$0(MemoizingProxy.java:114)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$Result.<init>(MemoizingProxy.java:40)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.lambda$intercept$1(MemoizingProxy.java:112)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.intercept(MemoizingProxy.java:112)
	at org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp$$EnhancerByCGLIB$$c609b70c.getBeans(<generated>)
	at org.springframework.ide.vscode.boot.java.livehover.LiveHoverUtils.findRelevantBeans(LiveHoverUtils.java:165)
	at org.springframework.ide.vscode.boot.java.livehover.LiveHoverUtils.hasRelevantBeans(LiveHoverUtils.java:161)
	at org.springframework.ide.vscode.boot.java.livehover.AbstractInjectedIntoHoverProvider.lambda$getLiveHintCodeLenses$0(AbstractInjectedIntoHoverProvider.java:67)
	at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
	at org.springframework.ide.vscode.boot.java.livehover.AbstractInjectedIntoHoverProvider.getLiveHintCodeLenses(AbstractInjectedIntoHoverProvider.java:67)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.extractLiveHintsForAnnotation(BootJavaHoverProvider.java:202)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider$1.visit(BootJavaHoverProvider.java:146)
	at org.eclipse.jdt.core.dom.MarkerAnnotation.accept0(MarkerAnnotation.java:124)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2868)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:439)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2868)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:255)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.lambda$getLiveHoverHints$0(BootJavaHoverProvider.java:108)
	at org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache.withCompilationUnit(CompilationUnitCache.java:120)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.getLiveHoverHints(BootJavaHoverProvider.java:104)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog.update(SpringLiveHoverWatchdog.java:190)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog.update(SpringLiveHoverWatchdog.java:172)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog$2.run(SpringLiveHoverWatchdog.java:119)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
[Timer-0] ERROR org.springframework.ide.vscode.commons.util.Log - Error
org.json.JSONException: JSONObject["aliases"] not found.
	at org.json.JSONObject.get(JSONObject.java:471)
	at org.json.JSONObject.getJSONArray(JSONObject.java:618)
	at org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel$Boot20Parser.parseBean(LiveBeansModel.java:145)
	at org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel$Boot20Parser.parse(LiveBeansModel.java:131)
	at org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel.parse(LiveBeansModel.java:171)
	at org.springframework.ide.vscode.commons.boot.app.cli.AbstractSpringBootApp.lambda$getBeans$2(AbstractSpringBootApp.java:225)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.boot.app.cli.AbstractSpringBootApp.getBeans(AbstractSpringBootApp.java:217)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649.CGLIB$getBeans$17(<generated>)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649$$FastClassByCGLIB$$f5a823d1.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.lambda$null$0(MemoizingProxy.java:73)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$Result.<init>(MemoizingProxy.java:40)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.lambda$intercept$1(MemoizingProxy.java:71)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$1.intercept(MemoizingProxy.java:71)
	at org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp$$EnhancerByCGLIB$$13ddc649.getBeans(<generated>)
	at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.lambda$null$0(MemoizingProxy.java:114)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$Result.<init>(MemoizingProxy.java:40)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.lambda$intercept$1(MemoizingProxy.java:112)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
	at org.springframework.ide.vscode.commons.util.MemoizingProxy$MemoizingProxyHandler.intercept(MemoizingProxy.java:112)
	at org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp$$EnhancerByCGLIB$$c609b70c.getBeans(<generated>)
	at org.springframework.ide.vscode.boot.java.livehover.LiveHoverUtils.findRelevantBeans(LiveHoverUtils.java:165)
	at org.springframework.ide.vscode.boot.java.livehover.LiveHoverUtils.hasRelevantBeans(LiveHoverUtils.java:161)
	at org.springframework.ide.vscode.boot.java.livehover.AbstractInjectedIntoHoverProvider.lambda$getLiveHintCodeLenses$0(AbstractInjectedIntoHoverProvider.java:67)
	at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
	at org.springframework.ide.vscode.boot.java.livehover.AbstractInjectedIntoHoverProvider.getLiveHintCodeLenses(AbstractInjectedIntoHoverProvider.java:67)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.extractLiveHintsForAnnotation(BootJavaHoverProvider.java:202)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider$1.visit(BootJavaHoverProvider.java:146)
	at org.eclipse.jdt.core.dom.MarkerAnnotation.accept0(MarkerAnnotation.java:124)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2868)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:439)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2868)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:255)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2797)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.lambda$getLiveHoverHints$0(BootJavaHoverProvider.java:108)
	at org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache.withCompilationUnit(CompilationUnitCache.java:120)
	at org.springframework.ide.vscode.boot.java.handlers.BootJavaHoverProvider.getLiveHoverHints(BootJavaHoverProvider.java:104)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog.update(SpringLiveHoverWatchdog.java:190)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog.update(SpringLiveHoverWatchdog.java:172)
	at org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog$2.run(SpringLiveHoverWatchdog.java:119)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
@philsttr
Copy link
Author

philsttr commented Sep 26, 2018

I think I figured out why. My app has an ObjectMapper bean configured with setSerializationInclusion(JsonInclude.Include.NON_DEFAULT) (for various app-specific reasons).

It appears that the JMX beans endpoint is using this mapper when serializing the bean information. This causes the aliases element to not be added to the json output.

Then when the Boot20Parser tries to read the aliases element, it throws an exception when it can't find it.

Would be nice to support this case. I guess you could fix it on the spring boot side (by adding appropriate JsonInclude annotations to the inner classes in BeansEndpoint, or using a different ObjectMapper instance) or the sts side (by handling missing elements properly)

@philsttr philsttr changed the title Live Boot Hint Decorators not working with Spring Boot 2.1.0.M4 Live Boot Hint Decorators not working when app ObjectMapper configured with NON_DEFAULT inclusion Sep 26, 2018
@martinlippert
Copy link
Member

@philsttr Awesome that you found the underlying reason for this. We should definitely improve our parsing to be more robust against those "unexpected" situations. Will put that in the list of things to improve for the next release.

@martinlippert martinlippert added this to the 4.0.1 milestone Sep 26, 2018
@kdvolder
Copy link
Member

to be more robust against those "unexpected" situations

Sounds like a good idea. But rather than try to anticipate all such unexpected cases it would be nice to have a example of the specific case that we are trying to fix here (would make for a great test case for our test suite).

@philsttr Any chance you could attach a sample project? Otherwise we will try to make one ourselves using the information you already provided. It would just help us a out a bit if you attached a sample.

@philsttr
Copy link
Author

Sure...

demo.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants