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 
December 05, 2019, 11:02:45 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: JPPFClient#submitJob throws Exception  (Read 2201 times)

Mariano

  • JPPF Padawan
  • *
  • Posts: 2
    • Medallia Engineering
JPPFClient#submitJob throws Exception
« on: August 12, 2014, 05:01:17 PM »

Hi all, is there a reason why JPPFClient#submitJob throws a plain Exception?

Looking at the code I couldn't find a reason. I'm using JPPF 4.2.

  @Override
  @SuppressWarnings("deprecation")
  public List<Task<?>> submitJob(final JPPFJob job) throws Exception {
    if (job == null) throw new IllegalArgumentException("job cannot be null");
    if (job.client != null) {
      if (!job.isDone()) throw new IllegalStateException("this job is already submitted");
      job.cancelled.set(false);
      job.getResults().clear();
    }
    job.client = this;
    if (job.getJobTasks().isEmpty()) throw new IllegalArgumentException("job cannot be empty");
    if ((job.getResultListener() == null) ||
        (job.isBlocking() && !(job.getResultListener() instanceof JPPFResultCollector))) job.setResultListener(new JPPFResultCollector(job));
    SubmissionManager submissionManager = getSubmissionManager();
    submissionManager.submitJob(job);
    if (job.isBlocking()) return job.awaitResults();
    return null;
  }


All explicitly thrown exceptions seem to be runtime exceptions, and none of the other invoked methods throw Exception. This forces whoever is using the client to either catch Exception or declare to throw it, but in reality this is never happening. Unless there's something I'm not seeing, hence I'm asking.

Thanks.
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2258
    • JPPF Web site
Re: JPPFClient#submitJob throws Exception
« Reply #1 on: August 12, 2014, 07:38:53 PM »

Hello,

You are absolutely right. I suppose we've carried this throws clause out of sheer inertia, as I cannot see any reason for it being there. I registered an enhancement for this: JPPF-305 JPPFClient.submitJob() has a useless throws clause. It will be delivered as part of the upcoming v4.2.1 maintenance release by the end of this week.

Thank you very much for reporting this issue.

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