Coder Social home page Coder Social logo

Comments (10)

OlivierMary avatar OlivierMary commented on June 12, 2024

Hi there, it's same error than #4 ?

from aw-watcher-jetbrains.

jdwil avatar jdwil commented on June 12, 2024

@OlivierMary I didn't notice any exception like that, but I need to re-enable the plugin today for some work, so I'll keep an eye out and post again if I see it, or anything else that is new.

from aw-watcher-jetbrains.

jdwil avatar jdwil commented on June 12, 2024

I just saw this error, but I haven't had any more issues with memory or sluggishness.

java.util.ConcurrentModificationException
	at java.base/java.util.ArrayList$Itr.checkForComodification(Unknown Source)
	at java.base/java.util.ArrayList$Itr.next(Unknown Source)
	at fr.mary.olivier.aw.watcher.ReportActivity.sendAllEvents(ReportActivity.java:192)
	at fr.mary.olivier.aw.watcher.ReportActivity.lambda$addAndSendEvent$2(ReportActivity.java:180)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:311)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

from aw-watcher-jetbrains.

OlivierMary avatar OlivierMary commented on June 12, 2024

Any steps to reproduce it ? Nobody can tell me how to reproduce, I tried many stress test while using IDEA and never had this error..

from aw-watcher-jetbrains.

jdwil avatar jdwil commented on June 12, 2024

Sorry, but I can't seem to reliably reproduce any of the issues. Sometimes I use PyCharm and Webstorm at the same time. Is it possible that that is impacting it?

from aw-watcher-jetbrains.

Martomate avatar Martomate commented on June 12, 2024

While I don't know the cause of the CPU and memory usage, I do have an idea about why the exception is thrown. Here is a stripped down version of the important code:

public static void addAndSendEvent( ... ) {
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        Event event = new Event( ... );
        getEventsToSend().add(event);
        sendAllEvents();
    });
}

private static synchronized void sendAllEvents() {
    for (Event event : getEventsToSend()) {
        // send the event
    }
}

private static synchronized List<Event> getEventsToSend() {
    return eventsToSend;
}

Imagine the following scenario:

  • Thread 1 enters addAndSendEvents.
  • A new thread is born, call it thread 2. It adds an event to the list and starts running the for loop.
  • Thread 1 goes on to do other things.
  • After a while thread 1 runs addAndSendEvents again.
  • A new thread is born, call it thread 3. It adds an event to the list, but since thread 1 is still running the for loop, thread 3 cannot enter sendAllEvents. It waits.
  • Thread 1 tries to run the next iteration of the for loop, but the list is modified and the exception is thrown.

The fact that ´getEventsToSend´ is synchronized doesn't really do much.

The solution? You can synchronize on the list, like this:

synchronize (eventsToSend) {
    // do things on the list
}

// other code

synchronize (eventsToSend) {
    // do other things on the list
}

If a thread is running one of these clauses, the other clause cannot be run and has to wait.

Hope this helps.

Have a nice day!

from aw-watcher-jetbrains.

OlivierMary avatar OlivierMary commented on June 12, 2024

@Martomate thanks will look at this !

from aw-watcher-jetbrains.

OlivierMary avatar OlivierMary commented on June 12, 2024

I post a new version 1.0.8 tell me if problem is solved. You can DL it from release page on github or wait 2-3d on Jetbrains plugins

from aw-watcher-jetbrains.

Martomate avatar Martomate commented on June 12, 2024

It seems to be solved. I haven't seen the error since your fix :)

from aw-watcher-jetbrains.

OlivierMary avatar OlivierMary commented on June 12, 2024

Great ! I close it :)

from aw-watcher-jetbrains.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.