Unable to Catch exception in java

2

Scenario:

I am using a project to manage MPT with Java.

I've got a piece of code like:

try {
    originalfilename = m_allFiles[i].getOriginalFileName();
} catch (Exception e)  {
    System.out.println("Exception Caught");
}

As I access the objects from different threads, sometimes this instruction throws an exception like be.derycke.pieter.com.COMException

Problem:

The message "Exception Caught" is never printed and console prints this stack trace:

be.derycke.pieter.com.COMException: Failed to retrieve the properties (0x800700aa)
    at jmtp.PortableDevicePropertiesImplWin32.getValues(Native Method)
    at jmtp.PortableDeviceObjectImplWin32.retrieveStringValue(Unknown Source)
    at jmtp.PortableDeviceObjectImplWin32.getOriginalFileName(Unknown Source)
    at com.servifot.kiosco.MobileCableSearcher$MobileFolderSearcher.run(MobileCableSearcher.java:284)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

The "MobileCableSearcher.java:284" line is what I have inside the try. So why the catch is not catching the exception?

More info:

The object which I call getOriginalFilename() is a PortableDeviceObject

I've tried to Catch a Throwable but the problem is exactly the same.

I've tried to specify the exception with be.derycke.pieter.com.COMException but I get this error: enter image description here

java
exception
try-catch
asked on Stack Overflow Dec 18, 2018 by Francesc MP

1 Answer

2

Exception is caught and reported in PortableDeviceObjectImplWin32.retrieveStringValue.

You will get null as result of getOriginalFileName in this case.

answered on Stack Overflow Dec 18, 2018 by talex

User contributions licensed under CC BY-SA 3.0