Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Don't wrap exceptions in MapperParsingException #121

Merged
merged 1 commit into from
Mar 31, 2015

Conversation

dadoonet
Copy link
Member

Some exceptions might not be serializable. It would be safer not to wrap them in a MapperParsingException but just create the MapperParsingException.

Related to #113.

@dadoonet dadoonet added this to the 2.5.0 milestone Mar 30, 2015
@dadoonet
Copy link
Member Author

@tlrx could you review that please?

@apogrebnyak
Copy link

How about using the same test as org.elasticsearch.transport.local.LocalTransportChannel.sendResponse and if exception is not serializable wrap it with NotSerializableTransportException?

NotSerializableTransportException has an added benefit of concatenating all messages from the exception chain.

@apogrebnyak
Copy link

Also, if you decide not to wrap with NotSerializableTransportException, can you add debug log before throwing?

@dadoonet
Copy link
Member Author

@apogrebnyak yeah I looked at it but actually to know if it's Serializable, you actually need to serialize it and catch the NotSerializableException. Here, I'm not sending any response over the wire like Transport layer actually does.
So it would require to create a new class which tries to Serialize the error. Not sure it worths it.

The simplest workaround is to simply send the error message and not the full error stack.

@dadoonet
Copy link
Member Author

About logging: yeah I agree.

@@ -451,7 +451,8 @@ public void parse(ParseContext context) throws IOException {

// #18: we could ignore errors when Tika does not parse data
if (!ignoreErrors) {
throw new MapperParsingException("Failed to extract [" + indexedChars + "] characters of text for [" + name + "]", e);
throw new MapperParsingException("Failed to extract [" + indexedChars + "] characters of text for [" + name + "] : "
+ e.getMessage());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add log before throwing the Exception. See #121 (comment)

@apogrebnyak
Copy link

In this case, maybe use NotSerializableTransportException to construct a message. Its advantage is that it lists all the messages from the chain that has lead to this exception. May be very useful in troubleshooting the problems

@tlrx
Copy link
Member

tlrx commented Mar 31, 2015

LGTM. Adding a complete message with root causes may be fine too but I think having the logs is enough.

Some exceptions might not be serializable. It would be safer not to wrap them in a `MapperParsingException` but just create the `MapperParsingException`.

Related to elastic#113.
@dadoonet dadoonet force-pushed the pr/mapper-parsing-exception branch from ccb1ca9 to e58878c Compare March 31, 2015 12:40
@dadoonet dadoonet merged commit e58878c into elastic:es-1.5 Mar 31, 2015
@dadoonet dadoonet deleted the pr/mapper-parsing-exception branch August 27, 2015 10:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants