Github user andymc12 commented on a diff in the pull request:

    https://github.com/apache/cxf/pull/301#discussion_r130889015
  
    --- Diff: 
rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/OutboundSseEventImpl.java ---
    @@ -24,24 +24,24 @@
     import javax.ws.rs.core.MediaType;
     import javax.ws.rs.sse.OutboundSseEvent;
     
    -public class OutboundSseEventImpl implements OutboundSseEvent {
    -    private String id;
    -    private String name;
    -    private String comment;
    -    private long reconnectDelay = -1;
    -    private Class<?> type;
    -    private Type genericType;
    -    private MediaType mediaType;
    -    private Object data;
    +public final class OutboundSseEventImpl implements OutboundSseEvent {
    +    private final String id;
    +    private final String name;
    +    private final String comment;
    +    private final long reconnectDelay;
    +    private final Class<?> type;
    +    private final Type genericType;
    +    private final MediaType mediaType;
    +    private final Object data;
     
         public static class BuilderImpl implements Builder {
             private String id;
             private String name;
             private String comment;
             private long reconnectDelay = -1;
    -        private Class<?> type;
    +        private Class<?> type = String.class;
    --- End diff --
    
    The use case here is for when a user uses the `data(String data)` API 
method (as opposed to the `data(Class<?> type, Object o)` method.  In the 
single parm case, the type is not set by the user, so we will get a NPE unless 
we set it - and since the API method accepts a String type, I think that makes 
the most sense.
    
    That said, I think I will make a change here - to avoid the case where the 
user uses _both_ API methods.  For example, they could do:
    `builder.data(Widget.class, new Widget(123)).data("my String");`
    
    I believe that this will cause the type to be set to Widget in the first 
call, but then not reset to String in the second call.  I'll change the 
defaulting to be in the implementation of the `data(String s)` method.
    
    Thanks for the review comments!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to