[TYRUS-253]  DecodeException is not passed to @OnError method from session.getAsyncRemote().sendObject Created: 17/Sep/13  Updated: 17/Sep/13  Resolved: 17/Sep/13

Status: Resolved
Project: tyrus
Component/s: core
Affects Version/s: 1.2.1
Fix Version/s: 1.3

Type: Bug Priority: Major
Reporter: jan.supol Assignee: Pavel Bucek
Resolution: Works as designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to TYRUS-251 DecodeException is not passed to @OnE... Resolved

 Description   
@ServerEndpoint(value = "/textstreamencoder", encoders = { ThrowingTextStreamEncoder.class })
public class WSCTextStreamEncoderServer {

	@OnMessage
	public void echo(String data, Session session) {
		session.getAsyncRemote().sendObject(new StringBean(data));
	}

	@OnError
	public void onError(Session session, Throwable t) throws IOException {
		String message = "TEST ERROR";
		session.getBasicRemote().sendText(message);
	}
}

public class ThrowingTextStreamEncoder implements TextStream<StringBean> {

	@Override
	public void encode(StringBean bean, Writer writer) throws EncodeException,
			IOException {
		throw new EncodeException(bean.get(), "ERROR");
	}
        ....
}

public class StringBean {
	private String value;

	public String get() {
		return value;
	}

	public StringBean(String value) {
		super();
		this.value = value;
	}
}



 Comments   
Comment by jan.supol [ 17/Sep/13 ]

looks like the same issue as TYRUS-251, except TYRUS-251 is about getBasicRemote().sendObject() and this is about getAsyncRemote().sendObject()

Comment by Pavel Bucek [ 17/Sep/13 ]

AsyncRemoteEndpoint.sendObject has different javadoc than BasicRemoteEndpoint alternative. You need to store returned future and call get(). Encode exception will be present as a cause of thrown ExecutionException.

Generated at Tue Jul 07 11:33:01 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.