Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Sep 23, 2024 8:32 pm

Hi all,

I'm getting the following NullPointerException when trying to read a PDF file that has a single table on it:

Exception in thread "java.lang.ThreadGroup[name=main,maxpri=10]_2" java.lang.NullPointerException: Cannot invoke "java.util.concurrent.ThreadPoolExecutor.shutdown()" because the return value of "com.spire.pdf.packages.sprwxt.spr■‣()" is null
at com.spire.pdf.packages.spruiu.spr╁¶(ThreadPool.java:117)
at com.spire.pdf.packages.sprblu.spr╁¶(Thread.java:66)
at com.spire.pdf.packages.sprteu.run(Thread.java:118)
at java.base/java.lang.Thread.run(Thread.java:1583)

It only seems to happen when I use the file in a JUnit test. This is a problem, though, because I need to know if my parsing is consistent. I'm also getting issues where it seems like the first row of the table is being skipped, although there is no exception thrown for that. The problem happens both when running tests in parallel and in series. It also only seems to show up if I run two or more tests with files like this, not if I run only one. I currently can't provide the file because it has confidential information in it, unfortunately, but I have attached a redacted image of it with generic text in the cells; hopefully you can make a test PDF file from the image.

The PDF file is a single page that has a company logo at the top, followed by a table with 6 columns. There are 30+ rows in the table. The first row is simple column header cells that don't span multiple rows. Cells in both the first and second columns span multiple rows, and cells in columns 3-6 don't. There are images in 2 cells in column 4. After the table, a date is in the lower right hand corner of the page.

I hope that's enough information to create a test.

jsrcastrogiovanni
 
Posts: 16
Joined: Thu Aug 22, 2024 6:02 pm

Tue Sep 24, 2024 6:26 am

Hello,

Thanks for your inquiry. I am currently unable to determine which specific feature you are using. If an error occurs while loading a PDF document (doc.loadFromFile()), the problem is likely related to the structure of your PDF document. Our simulated document may not be able to reproduce your problem. You can replace the sensitive data in the document and send it to us, and you can upload here or send it to us via email( support@e-iceblue.com ). In addition, if it is not an error when loading the document, please provide us with your complete test code for investigation, and we will use simulated documents for testing. Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Tue Sep 24, 2024 3:30 pm

Sent an email with the necessary files and tests attached.

jsrcastrogiovanni
 
Posts: 16
Joined: Thu Aug 22, 2024 6:02 pm

Wed Sep 25, 2024 8:55 am

Hello,

Thank you for your feedback. I tested your code in Junit (testing 3 'test3' documents each time) with the latest version Spire.PDF for Java Version:10.9.0, and I tested it no less than 10 times. However, the tests passed successfully and there was no issue of losing the first row of data when extracting the table. I have attached my test screenshot for your reference. If you are using an older version, I suggest you test it again with the latest version. If your project still has problems, you can provide us with your project that can help us reproduce your problem. You can upload your project and share the download link with us via email. Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Thu Sep 26, 2024 4:17 pm

Thank you,
There's definitely still something going on with the nullpointer, but I can't reproduce it consistently either (it never was consistent in the first place), and that's the problem. I'm going to work through my code and see if there's something I'm missing -- I'm using 10.9.0 -- so it's not an upgrade issue. Since the exception doesn't stop the test from completing, my instinct is that it's something in a background thread inside Spire.PDF that happens to be called but doesn't actually affect my particular use case.

jsrcastrogiovanni
 
Posts: 16
Joined: Thu Aug 22, 2024 6:02 pm

Fri Sep 27, 2024 5:46 am

Hello,

In order to accurately locate the cause of the problem, we may need your more assistance, if you can provide a complete project that can reproduce the problem, that will be helpful. Thank you in advance!

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Fri Sep 27, 2024 3:49 pm

The one that I sent should be able to reproduce it, at least, it does on my system. I know you tested it 10 times and didn't see the error, but I think that might just mean you need to keep running it; since it doesn't show up consistently I think it's just a matter of continuing to run it.

jsrcastrogiovanni
 
Posts: 16
Joined: Thu Aug 22, 2024 6:02 pm

Sun Sep 29, 2024 8:57 am

Hello,

Thanks for your feedback. According to your suggestion. I ran it again 10 times, but the test results were still normal. I am unable to reproduce your issue. As you mentioned, this error is sporadic and may require specific scenarios to reproduce. Additionally, I will provide you with my testing project for your reference, and you can run it on your side and provide us with feedback on the results. Finally, if our project scenarios are different, please adjust them on our project and send them to us. You can upload your project and share the download link with us. Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF