tyrus
  1. tyrus
  2. TYRUS-253

DecodeException is not passed to @OnError method from session.getAsyncRemote().sendObject

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.3
    • Component/s: core
    • Labels:
      None

      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;
      	}
      }
      
      

        Issue Links

          Activity

          Hide
          jan.supol added a comment - - edited

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

          Show
          jan.supol added a comment - - edited looks like the same issue as TYRUS-251 , except TYRUS-251 is about getBasicRemote().sendObject() and this is about getAsyncRemote().sendObject()
          Hide
          Pavel Bucek added a comment -

          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.

          Show
          Pavel Bucek added a comment - 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.

            People

            • Assignee:
              Pavel Bucek
              Reporter:
              jan.supol
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: