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

NullPointerException: Cannot invoke IProgressMonitor.beginTask(String, int) because monitor is null #173

Open
hangum opened this issue Feb 24, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@hangum
Copy link

hangum commented Feb 24, 2024

I am getting a null point error in monitor.beginTask("Beging prograss", IProgressMonitor.UNKNOWN);.
Repeat the NullPointException occurred and worked fine throughout the code that uses Job.
The code below has been working for a long time.
When it worked, it was using RAP 3.14.0.20200824, Java 1.8, Tomcat 8.5.x.

Where should I look?
Thanks in advance.

Environment:

  • EcliseRAP : rap-3.27.0-RC2a-20231205-1650
  • Tomcat : Apache Tomcat 9.0.86 or Tomcat 10.x
  • Java : Java 17.x or 21.x

Error description:

java.lang.NullPointerException: Cannot invoke "org.eclipse.core.runtime.IProgressMonitor.beginTask(String, int)" because "monitor" is null
	at com.xxxxTadpoleTableComposite$8.run(xxxTableComposite.java:733)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Sample Code:

final String MSG_LoadingData = CommonMessages.get().LoadingData;
	Job job = new Job(CommonMessages.get().ExecuteQuery) {
		@Override
		public IStatus run(IProgressMonitor monitor) {
			monitor.beginTask(MSG_LoadingData, IProgressMonitor.UNKNOWN);  <-----  null point exception
			
			try {
				listTablesDAO = TadpoleObjectQuery.getTableList(userDB);
			} catch(Exception e) {
				logger.error("Table Referesh", e); //$NON-NLS-1$
				
				return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage(), e);
			} finally {
				monitor.done();
			}
			
			return Status.OK_STATUS;
		}
	};
	
	job.addJobChangeListener(new JobChangeAdapter() {
		
		public void done(IJobChangeEvent event) {
			final IJobChangeEvent jobEvent = event; 
			
			final Display display = getSite().getShell().getDisplay();
			display.asyncExec(new Runnable() {
				public void run() {
					if(jobEvent.getResult().isOK()) {
						xxx
					} else {
						xxxx
					}	// end else if
					
					
				}	// end run
			});	// end display.asyncExec
			
		}	// end done
		
		
		
	});	// end job
	
	job.setName(userDB.getDisplay_name());
	job.setUser(false);
	job.schedule();
@hangum
Copy link
Author

hangum commented Feb 27, 2024

I modified the runtime to rap-3.22.0-R-20220906-0913 and it works fine.
I'll share a test site when I'm done with my busy work.

Thanks.

@mknauer mknauer added the bug Something isn't working label Feb 28, 2024
@mknauer
Copy link
Contributor

mknauer commented Feb 28, 2024

Thank you for your report!
Since you mention a "modified runtime" in your last comment: Can you share with us what you have changed, or even better, create a pull request?

@mknauer mknauer changed the title java.lang.NullPointerException: Cannot invoke "org.eclipse.core.runtime.IProgressMonitor.beginTask(String, int)" because "monitor" is null NullPointerException: Cannot invoke IProgressMonitor.beginTask(String, int) because monitor is null Mar 13, 2024
@dogla
Copy link

dogla commented Apr 4, 2024

We may have stumbled across the same problem: monitor == null.
Unfortunately, we don't have a minimal standalone example to reproduce the problem.
I suspect the problem is due to the following commit in the eclipse platform:
eclipse-platform/eclipse.platform@9c3525c

Previously, a NullProgressMonitor was used in the platform if a ProgressProvider returned null.
In RAP, at least in our case, the RAP-specific org.eclipse.rap.ui.internal.progress.JobManagerAdapter is called, which returns null under certain conditions.
At first glance, RAP behaves as before, only the eclipse platform now handles null results differently, which leads to these subsequent errors.

A quick fix could be to add the NullProgressMonitor fallback handling to the RAP specific JobManagerAdapter.

@dogla
Copy link

dogla commented Apr 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants