JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 
August 11, 2020, 09:25:51 PM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: NPE calling getAllJobIds() when thread was interrupted  (Read 1117 times)

codemonkey

  • JPPF Council Member
  • *****
  • Posts: 138
NPE calling getAllJobIds() when thread was interrupted
« on: October 01, 2014, 09:42:43 PM »

Hey Laurent, I ran into an issue where a thread is interrupted while making a call to the getAllJobIds() method, and it throws an NPE.

Exception:
Code: [Select]
java.lang.NullPointerException
at org.jppf.management.JMXConnectionWrapper.getAttribute(JMXConnectionWrapper.java:290)
at org.jppf.management.JMXDriverConnectionWrapper.getAllJobIds(JMXDriverConnectionWrapper.java:200)

At JMXConnectionWrapper.java:290  connectionThread.get()..isConnecting() will throw a NPE because the close() method isn't guarded:

Code: [Select]
if (!connectionThread.get().isConnecting()) connectionThread.get().resume();


Code: [Select]
/**
   * Close the connection to the remote MBean server.
   * @throws Exception if the connection could not be closed.
   */

  public void close() throws Exception {
//CM: Need to guard this...
    if (connectionThread.get() != null) connectionThread.get().close();
    connectionThread.set(null);
    if ((jmxc != null) && isConnected()) jmxc.close();
  }

Shouldn’t  close() use the same sync block as JMXConnectionWrapper.getAttribute()?
And JMXConnectionWrapper.getAttribute() should verify for null inside the sync block, not outside?

Code: [Select]
if (!isConnected() || ((connectionThread.get() != null) && connectionThread.get().isConnecting())) return null;
    synchronized(this) {
...............

Thanks in advance
CM


Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2262
    • JPPF Web site
Re: NPE calling getAllJobIds() when thread was interrupted
« Reply #1 on: October 02, 2014, 08:27:30 AM »

Hello CM,

I have registered this as bug JPPF-335 NPE in JMXConnectionWrapper.getAttribute(). I'm currently investigating how to reproduce and how to fix it. This may take some time, as the JMXConnectionWrapper code synchronization is pretty complex and prone to deadlocks if not done cautiously.  At the latest, a fix will be available for the next maintenance release v4.2.3, planned for mid-october.

Sincerely,
-Laurent
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads