@@ -63,6 +63,10 @@ public abstract class ProviderBase<
6363 */
6464 public final static String HEADER_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options" ;
6565
66+ protected final static String CLASS_NAME_NO_CONTENT_EXCEPTION = "javax.ws.rs.core.NoContentException" ;
67+
68+ private final static String NO_CONTENT_MESSAGE = "No content (empty input stream)" ;
69+
6670 /**
6771 * Looks like we need to worry about accidental
6872 * data binding for types we shouldn't be handling. This is
@@ -192,9 +196,6 @@ public abstract class ProviderBase<
192196 protected final LRUMap <AnnotationBundleKey , EP_CONFIG > _writers
193197 = new LRUMap <AnnotationBundleKey , EP_CONFIG >(16 , 120 );
194198
195- protected final AtomicReference <IOException > _noContentExceptionRef
196- = new AtomicReference <IOException >();
197-
198199 /*
199200 /**********************************************************
200201 /* Life-cycle
@@ -207,9 +208,8 @@ protected ProviderBase(MAPPER_CONFIG mconfig) {
207208 }
208209
209210 /**
210- * Constructor that is only added to resolve
211- * issue #10; problems with combination of
212- * RESTeasy and CDI.
211+ * Constructor that is only added to resolve [jaxrs-providers#10]; problems
212+ * with combination of RESTeasy and CDI.
213213 * Should NOT be used by any code explicitly; only exists
214214 * for proxy support.
215215 */
@@ -554,9 +554,8 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat
554554 // negation: Boolean.TRUE means untouchable -> can not write
555555 return !customUntouchable .booleanValue ();
556556 }
557- /* Ok: looks like we must weed out some core types here; ones that
558- * make no sense to try to bind from JSON:
559- */
557+ // Ok: looks like we must weed out some core types here; ones that
558+ // make no sense to try to bind from JSON:
560559 if (_isIgnorableForWriting (new ClassKey (type ))) {
561560 return false ;
562561 }
@@ -751,9 +750,8 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati
751750 // negation: Boolean.TRUE means untouchable -> can not write
752751 return !customUntouchable .booleanValue ();
753752 }
754- /* Ok: looks like we must weed out some core types here; ones that
755- * make no sense to try to bind from JSON:
756- */
753+ // Ok: looks like we must weed out some core types here; ones that
754+ // make no sense to try to bind from JSON:
757755 if (_isIgnorableForReading (new ClassKey (type ))) {
758756 return false ;
759757 }
@@ -797,14 +795,11 @@ public Object readFrom(Class<Object> type, Type genericType, Annotation[] annota
797795 if (JaxRSFeature .ALLOW_EMPTY_INPUT .enabledIn (_jaxRSFeatures )) {
798796 return null ;
799797 }
800- /* 05-Apr-2014, tatu: Trick-ee. NoContentFoundException only available in JAX-RS 2.0...
801- * so need bit of obfuscated code to reach it.
802- */
803- IOException fail = _noContentExceptionRef .get ();
804- if (fail == null ) {
805- fail = _createNoContentException ();
806- }
807- throw fail ;
798+ // 05-Apr-2014, tatu: Trick-ee. NoContentFoundException only available in JAX-RS 2.0...
799+ // so need bit of obfuscated code to reach it.
800+
801+ // 20-Jan-2021, tatu: as per [jaxrs-providers#134], simplify
802+ throw _createNoContentException ();
808803 }
809804 Class <?> rawType = type ;
810805 if (rawType == JsonParser .class ) {
@@ -990,13 +985,9 @@ protected boolean _isIgnorableForWriting(ClassKey typeKey)
990985 {
991986 return _untouchables .contains (typeKey );
992987 }
993-
994- /**
995- * @since 2.4
996- */
997- protected IOException _createNoContentException ()
998- {
999- return new NoContentException ("No content (empty input stream)" );
988+
989+ protected IOException _createNoContentException () {
990+ return new NoContentException (NO_CONTENT_MESSAGE );
1000991 }
1001992
1002993 /*
0 commit comments