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

9
  • 2
    Can you identify code that print this message? Is it possible that message is printed inside the lib and exception is newer thrown from getOriginalFileName? Commented Dec 18, 2018 at 10:26
  • 2
    be.derycke.pieter.com.COMException is a checked exception and thus can't be thrown by PortableDeviceObject.getOriginalFilename() because it doesn't declare that exception to be thrown and implementing methods are not allowed to add a throws declaration. Commented Dec 18, 2018 at 10:27
  • Unrelated: please learn about java naming conventions. Using "m_" hungarian notation style naming schemes are discouraged for java source code. Commented Dec 18, 2018 at 10:29
  • Check your log. It should contain line "Errror in retrieveStringValue. HRESULT" right before exception. Commented Dec 18, 2018 at 10:30
  • Further to @Thomas comment, if you put a println after the quoted code, is that executed? Commented Dec 18, 2018 at 10:31

1 Answer 1

2

Exception is caught and reported in PortableDeviceObjectImplWin32.retrieveStringValue.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.