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

Fixed a bug related to tree path encoder. #944

Merged
merged 2 commits into from
Sep 30, 2022
Merged

Conversation

OlliKiljunen
Copy link
Member

Description of the PR

Error reported with the following stack trace:

Stack trace
java.lang.IllegalStateException: Recursive update
  at java.base/java.util.concurrent.ConcurrentHashMap.transfer(ConcurrentHashMap.java:2552)
  at java.base/java.util.concurrent.ConcurrentHashMap.tryPresize(ConcurrentHashMap.java:2415)
  at java.base/java.util.concurrent.ConcurrentHashMap.treeifyBin(ConcurrentHashMap.java:2669)
  at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1768)
  at fi.aalto.cs.apluscourses.ui.utils.TreePathEncoder.encode(TreePathEncoder.java:13)
  at fi.aalto.cs.apluscourses.ui.utils.TreePathEncoder.encodeInternal(TreePathEncoder.java:17)
  at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
  at fi.aalto.cs.apluscourses.ui.utils.TreePathEncoder.encode(TreePathEncoder.java:13)
  at fi.aalto.cs.apluscourses.ui.base.TreeView.lambda$restoreExpandedState$0(TreeView.java:156)
  at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
  at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411)
  at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
  at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
  at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
  at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
  at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
  at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
  at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
  at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
  at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
  at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
  at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
  at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
  at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
  at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
  at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
  at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
  at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
  at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
  at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
  at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
  at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
  at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
  at fi.aalto.cs.apluscourses.ui.base.TreeView.restoreExpandedState(TreeView.java:157)
  at fi.aalto.cs.apluscourses.ui.base.TreeView.update(TreeView.java:121)
  at fi.aalto.cs.apluscourses.ui.base.TreeView.setViewModel(TreeView.java:95)
  at fi.aalto.cs.apluscourses.ui.exercise.ExercisesView$ExercisesTreeView.setViewModel(ExercisesView.java:139)
  at fi.aalto.cs.apluscourses.ui.exercise.ExercisesView.lambda$viewModelChanged$0(ExercisesView.java:78)
  at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:194)
  at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
  at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
  at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
  at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
  at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
  at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
  at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
  at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
  at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
  at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
  at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
  at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
  at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:918)
  at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:766)
  at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450)
  at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
  at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449)
  at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
  at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624)
  at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447)
  at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
  at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)
  at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
  at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
  at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
  at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
  at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
  at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

The problem was that TreePathEncoder used ConcurrentHashMap to memoize a recursive function, which that class does not support (the issue was unclear still in Java 8). This PR fixes the bug.

}
T value = memo.get(treePath);
if (value == null) {
value = encodeInternal(treePath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two spaces before encodeInternal

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 18 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@OlliKiljunen OlliKiljunen merged commit daff437 into master Sep 30, 2022
@OlliKiljunen OlliKiljunen deleted the tree-path-encoder-fix branch September 30, 2022 09:49
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

Successfully merging this pull request may close these issues.

2 participants