1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.websocket.jsr356.encoders;
20
21 import java.util.concurrent.ExecutionException;
22 import java.util.concurrent.Future;
23 import java.util.concurrent.TimeUnit;
24 import java.util.concurrent.TimeoutException;
25
26 import javax.websocket.Encoder;
27
28
29
30
31 public class EncodeFailedFuture implements Future<Void>
32 {
33 private final String msg;
34 private final Throwable cause;
35
36 public EncodeFailedFuture(Object data, Encoder encoder, Class<?> encoderType, Throwable cause)
37 {
38 this.msg = String.format("Unable to encode %s using %s as %s",data.getClass().getName(),encoder.getClass().getName(),encoderType.getName());
39 this.cause = cause;
40 }
41
42 @Override
43 public boolean cancel(boolean mayInterruptIfRunning)
44 {
45 return false;
46 }
47
48 @Override
49 public Void get() throws InterruptedException, ExecutionException
50 {
51 throw new ExecutionException(msg,cause);
52 }
53
54 @Override
55 public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
56 {
57 throw new ExecutionException(msg,cause);
58 }
59
60 @Override
61 public boolean isCancelled()
62 {
63 return false;
64 }
65
66 @Override
67 public boolean isDone()
68 {
69 return true;
70 }
71 }