Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 73086200CE7 for ; Wed, 2 Aug 2017 16:18:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 717EE168ED8; Wed, 2 Aug 2017 14:18:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B656F168DCF for ; Wed, 2 Aug 2017 16:18:04 +0200 (CEST) Received: (qmail 57461 invoked by uid 500); 2 Aug 2017 14:18:03 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 57450 invoked by uid 99); 2 Aug 2017 14:18:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 14:18:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4B1F71805BF for ; Wed, 2 Aug 2017 14:18:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id c2I4eNEhCXLO for ; Wed, 2 Aug 2017 14:18:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 090D25FB57 for ; Wed, 2 Aug 2017 14:18:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 52C21E08F4 for ; Wed, 2 Aug 2017 14:18:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id E88AB2464C for ; Wed, 2 Aug 2017 14:18:00 +0000 (UTC) Date: Wed, 2 Aug 2017 14:18:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-7462) OutboundSseEventImpl could use some minor tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 02 Aug 2017 14:18:05 -0000 [ https://issues.apache.org/jira/browse/CXF-7462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16110983#comment-16110983 ] ASF GitHub Bot commented on CXF-7462: ------------------------------------- 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! > OutboundSseEventImpl could use some minor tweaks > ------------------------------------------------ > > Key: CXF-7462 > URL: https://issues.apache.org/jira/browse/CXF-7462 > Project: CXF > Issue Type: Improvement > Components: JAX-RS > Affects Versions: 3.2.0 > Reporter: Andy McCright > Priority: Minor > Fix For: 3.2.0 > > > The OutboundSseEventImpl class could use some minor tweaks, including: > 1) Make the fields final to reflect that the event is immutable. > 2) Use defaults for the data type (String.class) and media type (SERVER_SENT_EVENT_TYPE). > 3) Restrict the constructor's visibility. > I also plan to add some tests for these changes. -- This message was sent by Atlassian JIRA (v6.4.14#64029)