juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [1/5] incubator-juneau-website git commit: Update javadocs.
Date Tue, 02 May 2017 16:44:22 GMT
Repository: incubator-juneau-website
Updated Branches:
  refs/heads/asf-site e12f8e7d7 -> 29e3a9ea4


http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/29e3a9ea/content/site/apidocs/src-html/org/apache/juneau/http/Accept.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/http/Accept.html b/content/site/apidocs/src-html/org/apache/juneau/http/Accept.html
index 12fd25e..272770a 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/http/Accept.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/http/Accept.html
@@ -130,7 +130,7 @@
 <span class="sourceLineNo">122</span> */<a name="line.122"></a>
 <span class="sourceLineNo">123</span>public final class Accept {<a name="line.123"></a>
 <span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>   private static final boolean nocache = Boolean.getBoolean("juneau.nocache");<a name="line.125"></a>
+<span class="sourceLineNo">125</span>   private static final boolean nocache = Boolean.getBoolean("juneau.http.Accept.nocache");<a name="line.125"></a>
 <span class="sourceLineNo">126</span>   private static final ConcurrentHashMap&lt;String,Accept&gt; cache = new ConcurrentHashMap&lt;String,Accept&gt;();<a name="line.126"></a>
 <span class="sourceLineNo">127</span><a name="line.127"></a>
 <span class="sourceLineNo">128</span>   private final MediaTypeRange[] mediaRanges;<a name="line.128"></a>
@@ -140,103 +140,109 @@
 <span class="sourceLineNo">132</span>    * Returns a parsed &lt;code&gt;Accept&lt;/code&gt; header.<a name="line.132"></a>
 <span class="sourceLineNo">133</span>    *<a name="line.133"></a>
 <span class="sourceLineNo">134</span>    * @param s The &lt;code&gt;Accept&lt;/code&gt; header string.<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    * @return The parsed &lt;code&gt;Accept&lt;/code&gt; header.<a name="line.135"></a>
+<span class="sourceLineNo">135</span>    * @return The parsed &lt;code&gt;Accept&lt;/code&gt; header, or &lt;jk&gt;null&lt;/jk&gt; if the string was null.<a name="line.135"></a>
 <span class="sourceLineNo">136</span>    */<a name="line.136"></a>
 <span class="sourceLineNo">137</span>   public static Accept forString(String s) {<a name="line.137"></a>
 <span class="sourceLineNo">138</span>      if (s == null)<a name="line.138"></a>
-<span class="sourceLineNo">139</span>         s = "null";<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      Accept a = cache.get(s);<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      if (a == null) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>         a = new Accept(s);<a name="line.142"></a>
-<span class="sourceLineNo">143</span>         if (nocache)<a name="line.143"></a>
-<span class="sourceLineNo">144</span>            return a;<a name="line.144"></a>
-<span class="sourceLineNo">145</span>         cache.putIfAbsent(s, a);<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      }<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      return cache.get(s);<a name="line.147"></a>
-<span class="sourceLineNo">148</span>   }<a name="line.148"></a>
-<span class="sourceLineNo">149</span><a name="line.149"></a>
-<span class="sourceLineNo">150</span>   private Accept(String raw) {<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      this.mediaRanges = MediaTypeRange.parse(raw);<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      this.mediaRangesList = Collections.unmodifiableList(Arrays.asList(mediaRanges));<a name="line.152"></a>
-<span class="sourceLineNo">153</span>   }<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>   /**<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    * Returns the list of the media ranges that make up this header.<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    * &lt;p&gt;<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    * The media ranges in the list are sorted by their q-value in descending order.<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    *<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    * @return An unmodifiable list of media ranges.<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    */<a name="line.161"></a>
-<span class="sourceLineNo">162</span>   public List&lt;MediaTypeRange&gt; getMediaRanges() {<a name="line.162"></a>
-<span class="sourceLineNo">163</span>      return mediaRangesList;<a name="line.163"></a>
-<span class="sourceLineNo">164</span>   }<a name="line.164"></a>
-<span class="sourceLineNo">165</span><a name="line.165"></a>
-<span class="sourceLineNo">166</span>   /**<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    * Given a list of media types, returns the best match for this &lt;code&gt;Accept&lt;/code&gt; header.<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    * &lt;p&gt;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    * Note that fuzzy matching is allowed on the media types where the &lt;code&gt;Accept&lt;/code&gt; header may<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    * contain additional subtype parts.<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    * &lt;br&gt;For example, given identical q-values and an &lt;code&gt;Accept&lt;/code&gt; value of &lt;js&gt;"text/json+activity"&lt;/js&gt;,<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    * the media type &lt;js&gt;"text/json"&lt;/js&gt; will match if &lt;js&gt;"text/json+activity"&lt;/js&gt; or &lt;js&gt;"text/activity+json"&lt;/js&gt;<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    * isn't found.<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    * &lt;br&gt;The purpose for this is to allow serializers to match when artifacts such as &lt;code&gt;id&lt;/code&gt; properties are present<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    * in the header.<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    * &lt;p&gt;<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    * See &lt;a class='doclink' href='https://www.w3.org/TR/activitypub/#retrieving-objects'&gt;ActivityPub / Retrieving Objects&lt;/a&gt;<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    * &lt;p&gt;<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    *<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    * @param mediaTypes The media types to match against.<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    */<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   public int findMatch(MediaType[] mediaTypes) {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      int matchQuant = 0, matchIndex = -1;<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      float q = 0f;<a name="line.185"></a>
-<span class="sourceLineNo">186</span><a name="line.186"></a>
-<span class="sourceLineNo">187</span>      // Media ranges are ordered by 'q'.<a name="line.187"></a>
-<span class="sourceLineNo">188</span>      // So we only need to search until we've found a match.<a name="line.188"></a>
-<span class="sourceLineNo">189</span>      for (MediaTypeRange mr : mediaRanges) {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>         float q2 = mr.getQValue();<a name="line.190"></a>
-<span class="sourceLineNo">191</span><a name="line.191"></a>
-<span class="sourceLineNo">192</span>         if (q2 &lt; q || q2 == 0)<a name="line.192"></a>
-<span class="sourceLineNo">193</span>            break;<a name="line.193"></a>
-<span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>         for (int i = 0; i &lt; mediaTypes.length; i++) {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>            MediaType mt = mediaTypes[i];<a name="line.196"></a>
-<span class="sourceLineNo">197</span>            int matchQuant2 = mt.match(mr.getMediaType());<a name="line.197"></a>
-<span class="sourceLineNo">198</span>            if (matchQuant2 &gt; matchQuant) {<a name="line.198"></a>
-<span class="sourceLineNo">199</span>               matchIndex = i;<a name="line.199"></a>
-<span class="sourceLineNo">200</span>               matchQuant = matchQuant2;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>               q = q2;<a name="line.201"></a>
-<span class="sourceLineNo">202</span>            }<a name="line.202"></a>
-<span class="sourceLineNo">203</span>         }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      }<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span>      return matchIndex;<a name="line.206"></a>
-<span class="sourceLineNo">207</span>   }<a name="line.207"></a>
-<span class="sourceLineNo">208</span><a name="line.208"></a>
-<span class="sourceLineNo">209</span>   /**<a name="line.209"></a>
-<span class="sourceLineNo">210</span>    * Convenience method for searching through all of the subtypes of all the media ranges in this header<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    * for the presence of a subtype fragment.<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    * &lt;p&gt;<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    * For example, given the header &lt;js&gt;"text/json+activity"&lt;/js&gt;, calling &lt;code&gt;hasSubtypePart(&lt;js&gt;"activity"&lt;/js&gt;)&lt;/code&gt; returns &lt;jk&gt;true&lt;/jk&gt;.<a name="line.213"></a>
-<span class="sourceLineNo">214</span>    *<a name="line.214"></a>
-<span class="sourceLineNo">215</span>    * @param part The media type subtype fragment.<a name="line.215"></a>
-<span class="sourceLineNo">216</span>    * @return &lt;jk&gt;true&lt;/jk&gt; if subtype fragement exists.<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    */<a name="line.217"></a>
-<span class="sourceLineNo">218</span>   public boolean hasSubtypePart(String part) {<a name="line.218"></a>
-<span class="sourceLineNo">219</span><a name="line.219"></a>
-<span class="sourceLineNo">220</span>      for (MediaTypeRange mr : this.mediaRanges)<a name="line.220"></a>
-<span class="sourceLineNo">221</span>         if (mr.getQValue() &gt; 0 &amp;&amp; mr.getMediaType().getSubTypes().indexOf(part) &gt;= 0)<a name="line.221"></a>
-<span class="sourceLineNo">222</span>            return true;<a name="line.222"></a>
-<span class="sourceLineNo">223</span><a name="line.223"></a>
-<span class="sourceLineNo">224</span>      return false;<a name="line.224"></a>
-<span class="sourceLineNo">225</span>   }<a name="line.225"></a>
-<span class="sourceLineNo">226</span><a name="line.226"></a>
-<span class="sourceLineNo">227</span>   @Override /* Object */<a name="line.227"></a>
-<span class="sourceLineNo">228</span>   public String toString() {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>      return StringUtils.join(mediaRanges, ',');<a name="line.229"></a>
-<span class="sourceLineNo">230</span>   }<a name="line.230"></a>
-<span class="sourceLineNo">231</span>}<a name="line.231"></a>
+<span class="sourceLineNo">139</span>         return null;<a name="line.139"></a>
+<span class="sourceLineNo">140</span><a name="line.140"></a>
+<span class="sourceLineNo">141</span>      // Prevent OOM in case of DDOS<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      if (cache.size() &gt; 1000)<a name="line.142"></a>
+<span class="sourceLineNo">143</span>         cache.clear();<a name="line.143"></a>
+<span class="sourceLineNo">144</span><a name="line.144"></a>
+<span class="sourceLineNo">145</span>      while (true) {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>         Accept a = cache.get(s);<a name="line.146"></a>
+<span class="sourceLineNo">147</span>         if (a != null)<a name="line.147"></a>
+<span class="sourceLineNo">148</span>            return a;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>         a = new Accept(s);<a name="line.149"></a>
+<span class="sourceLineNo">150</span>         if (nocache)<a name="line.150"></a>
+<span class="sourceLineNo">151</span>            return a;<a name="line.151"></a>
+<span class="sourceLineNo">152</span>         cache.putIfAbsent(s, a);<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      }<a name="line.153"></a>
+<span class="sourceLineNo">154</span>   }<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>   private Accept(String raw) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      this.mediaRanges = MediaTypeRange.parse(raw);<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      this.mediaRangesList = Collections.unmodifiableList(Arrays.asList(mediaRanges));<a name="line.158"></a>
+<span class="sourceLineNo">159</span>   }<a name="line.159"></a>
+<span class="sourceLineNo">160</span><a name="line.160"></a>
+<span class="sourceLineNo">161</span>   /**<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    * Returns the list of the media ranges that make up this header.<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    * &lt;p&gt;<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    * The media ranges in the list are sorted by their q-value in descending order.<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    *<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    * @return An unmodifiable list of media ranges.<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    */<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   public List&lt;MediaTypeRange&gt; getMediaRanges() {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>      return mediaRangesList;<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   }<a name="line.170"></a>
+<span class="sourceLineNo">171</span><a name="line.171"></a>
+<span class="sourceLineNo">172</span>   /**<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    * Given a list of media types, returns the best match for this &lt;code&gt;Accept&lt;/code&gt; header.<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    * &lt;p&gt;<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    * Note that fuzzy matching is allowed on the media types where the &lt;code&gt;Accept&lt;/code&gt; header may<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    * contain additional subtype parts.<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    * &lt;br&gt;For example, given identical q-values and an &lt;code&gt;Accept&lt;/code&gt; value of &lt;js&gt;"text/json+activity"&lt;/js&gt;,<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    * the media type &lt;js&gt;"text/json"&lt;/js&gt; will match if &lt;js&gt;"text/json+activity"&lt;/js&gt; or &lt;js&gt;"text/activity+json"&lt;/js&gt;<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    * isn't found.<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    * &lt;br&gt;The purpose for this is to allow serializers to match when artifacts such as &lt;code&gt;id&lt;/code&gt; properties are present<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    * in the header.<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    * &lt;p&gt;<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    * See &lt;a class='doclink' href='https://www.w3.org/TR/activitypub/#retrieving-objects'&gt;ActivityPub / Retrieving Objects&lt;/a&gt;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    * &lt;p&gt;<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    *<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    * @param mediaTypes The media types to match against.<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    */<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   public int findMatch(MediaType[] mediaTypes) {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      int matchQuant = 0, matchIndex = -1;<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      float q = 0f;<a name="line.191"></a>
+<span class="sourceLineNo">192</span><a name="line.192"></a>
+<span class="sourceLineNo">193</span>      // Media ranges are ordered by 'q'.<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      // So we only need to search until we've found a match.<a name="line.194"></a>
+<span class="sourceLineNo">195</span>      for (MediaTypeRange mr : mediaRanges) {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>         float q2 = mr.getQValue();<a name="line.196"></a>
+<span class="sourceLineNo">197</span><a name="line.197"></a>
+<span class="sourceLineNo">198</span>         if (q2 &lt; q || q2 == 0)<a name="line.198"></a>
+<span class="sourceLineNo">199</span>            break;<a name="line.199"></a>
+<span class="sourceLineNo">200</span><a name="line.200"></a>
+<span class="sourceLineNo">201</span>         for (int i = 0; i &lt; mediaTypes.length; i++) {<a name="line.201"></a>
+<span class="sourceLineNo">202</span>            MediaType mt = mediaTypes[i];<a name="line.202"></a>
+<span class="sourceLineNo">203</span>            int matchQuant2 = mt.match(mr.getMediaType());<a name="line.203"></a>
+<span class="sourceLineNo">204</span>            if (matchQuant2 &gt; matchQuant) {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>               matchIndex = i;<a name="line.205"></a>
+<span class="sourceLineNo">206</span>               matchQuant = matchQuant2;<a name="line.206"></a>
+<span class="sourceLineNo">207</span>               q = q2;<a name="line.207"></a>
+<span class="sourceLineNo">208</span>            }<a name="line.208"></a>
+<span class="sourceLineNo">209</span>         }<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      }<a name="line.210"></a>
+<span class="sourceLineNo">211</span><a name="line.211"></a>
+<span class="sourceLineNo">212</span>      return matchIndex;<a name="line.212"></a>
+<span class="sourceLineNo">213</span>   }<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>   /**<a name="line.215"></a>
+<span class="sourceLineNo">216</span>    * Convenience method for searching through all of the subtypes of all the media ranges in this header<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    * for the presence of a subtype fragment.<a name="line.217"></a>
+<span class="sourceLineNo">218</span>    * &lt;p&gt;<a name="line.218"></a>
+<span class="sourceLineNo">219</span>    * For example, given the header &lt;js&gt;"text/json+activity"&lt;/js&gt;, calling &lt;code&gt;hasSubtypePart(&lt;js&gt;"activity"&lt;/js&gt;)&lt;/code&gt; returns &lt;jk&gt;true&lt;/jk&gt;.<a name="line.219"></a>
+<span class="sourceLineNo">220</span>    *<a name="line.220"></a>
+<span class="sourceLineNo">221</span>    * @param part The media type subtype fragment.<a name="line.221"></a>
+<span class="sourceLineNo">222</span>    * @return &lt;jk&gt;true&lt;/jk&gt; if subtype fragement exists.<a name="line.222"></a>
+<span class="sourceLineNo">223</span>    */<a name="line.223"></a>
+<span class="sourceLineNo">224</span>   public boolean hasSubtypePart(String part) {<a name="line.224"></a>
+<span class="sourceLineNo">225</span><a name="line.225"></a>
+<span class="sourceLineNo">226</span>      for (MediaTypeRange mr : this.mediaRanges)<a name="line.226"></a>
+<span class="sourceLineNo">227</span>         if (mr.getQValue() &gt; 0 &amp;&amp; mr.getMediaType().getSubTypes().indexOf(part) &gt;= 0)<a name="line.227"></a>
+<span class="sourceLineNo">228</span>            return true;<a name="line.228"></a>
+<span class="sourceLineNo">229</span><a name="line.229"></a>
+<span class="sourceLineNo">230</span>      return false;<a name="line.230"></a>
+<span class="sourceLineNo">231</span>   }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>   @Override /* Object */<a name="line.233"></a>
+<span class="sourceLineNo">234</span>   public String toString() {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>      return StringUtils.join(mediaRanges, ',');<a name="line.235"></a>
+<span class="sourceLineNo">236</span>   }<a name="line.236"></a>
+<span class="sourceLineNo">237</span>}<a name="line.237"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/29e3a9ea/content/site/apidocs/src-html/org/apache/juneau/http/AcceptEncoding.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/http/AcceptEncoding.html b/content/site/apidocs/src-html/org/apache/juneau/http/AcceptEncoding.html
index 96b017e..bbf4248 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/http/AcceptEncoding.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/http/AcceptEncoding.html
@@ -88,7 +88,7 @@
 <span class="sourceLineNo">080</span> */<a name="line.80"></a>
 <span class="sourceLineNo">081</span>public final class AcceptEncoding {<a name="line.81"></a>
 <span class="sourceLineNo">082</span><a name="line.82"></a>
-<span class="sourceLineNo">083</span>   private static final boolean nocache = Boolean.getBoolean("juneau.nocache");<a name="line.83"></a>
+<span class="sourceLineNo">083</span>   private static final boolean nocache = Boolean.getBoolean("juneau.http.AcceptEncoding.nocache");<a name="line.83"></a>
 <span class="sourceLineNo">084</span>   private static final ConcurrentHashMap&lt;String,AcceptEncoding&gt; cache = new ConcurrentHashMap&lt;String,AcceptEncoding&gt;();<a name="line.84"></a>
 <span class="sourceLineNo">085</span><a name="line.85"></a>
 <span class="sourceLineNo">086</span>   private final TypeRange[] typeRanges;<a name="line.86"></a>
@@ -98,61 +98,67 @@
 <span class="sourceLineNo">090</span>    * Returns a parsed &lt;code&gt;Accept-Encoding&lt;/code&gt; header.<a name="line.90"></a>
 <span class="sourceLineNo">091</span>    *<a name="line.91"></a>
 <span class="sourceLineNo">092</span>    * @param s The &lt;code&gt;Accept-Encoding&lt;/code&gt; header string.<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    * @return The parsed &lt;code&gt;Accept-Encoding&lt;/code&gt; header.<a name="line.93"></a>
+<span class="sourceLineNo">093</span>    * @return The parsed &lt;code&gt;Accept-Encoding&lt;/code&gt; header, or &lt;jk&gt;null&lt;/jk&gt; if the string was null.<a name="line.93"></a>
 <span class="sourceLineNo">094</span>    */<a name="line.94"></a>
 <span class="sourceLineNo">095</span>   public static AcceptEncoding forString(String s) {<a name="line.95"></a>
 <span class="sourceLineNo">096</span>      if (s == null)<a name="line.96"></a>
-<span class="sourceLineNo">097</span>         s = "null";<a name="line.97"></a>
-<span class="sourceLineNo">098</span>      AcceptEncoding a = cache.get(s);<a name="line.98"></a>
-<span class="sourceLineNo">099</span>      if (a == null) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>         a = new AcceptEncoding(s);<a name="line.100"></a>
-<span class="sourceLineNo">101</span>         if (nocache)<a name="line.101"></a>
-<span class="sourceLineNo">102</span>            return a;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>         cache.putIfAbsent(s, a);<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      }<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      return cache.get(s);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>   }<a name="line.106"></a>
-<span class="sourceLineNo">107</span><a name="line.107"></a>
-<span class="sourceLineNo">108</span>   private AcceptEncoding(String raw) {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      this.typeRanges = TypeRange.parse(raw);<a name="line.109"></a>
-<span class="sourceLineNo">110</span>      this.typeRangesList = Collections.unmodifiableList(Arrays.asList(typeRanges));<a name="line.110"></a>
-<span class="sourceLineNo">111</span>   }<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>   /**<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    * Returns the list of the types ranges that make up this header.<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    * &lt;p&gt;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    * The types ranges in the list are sorted by their q-value in descending order.<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    *<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    * @return An unmodifiable list of type ranges.<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    */<a name="line.119"></a>
-<span class="sourceLineNo">120</span>   public List&lt;TypeRange&gt; getTypeRanges() {<a name="line.120"></a>
-<span class="sourceLineNo">121</span>      return typeRangesList;<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   }<a name="line.122"></a>
-<span class="sourceLineNo">123</span><a name="line.123"></a>
-<span class="sourceLineNo">124</span>   /**<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    * Given a list of content codings, returns the best match for this &lt;code&gt;Accept-Encoding&lt;/code&gt; header.<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    * &lt;p&gt;<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    *<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    * @param contentCodings The codings to match against.<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    */<a name="line.130"></a>
-<span class="sourceLineNo">131</span>   public int findMatch(String[] contentCodings) {<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>      // Type ranges are ordered by 'q'.<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      // So we only need to search until we've found a match.<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      for (TypeRange mr : typeRanges)<a name="line.135"></a>
-<span class="sourceLineNo">136</span>         for (int i = 0; i &lt; contentCodings.length; i++)<a name="line.136"></a>
-<span class="sourceLineNo">137</span>            if (mr.matches(contentCodings[i]))<a name="line.137"></a>
-<span class="sourceLineNo">138</span>               return i;<a name="line.138"></a>
-<span class="sourceLineNo">139</span><a name="line.139"></a>
-<span class="sourceLineNo">140</span>      return -1;<a name="line.140"></a>
-<span class="sourceLineNo">141</span>   }<a name="line.141"></a>
-<span class="sourceLineNo">142</span><a name="line.142"></a>
-<span class="sourceLineNo">143</span>   @Override /* Object */<a name="line.143"></a>
-<span class="sourceLineNo">144</span>   public String toString() {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>      return StringUtils.join(typeRanges, ',');<a name="line.145"></a>
-<span class="sourceLineNo">146</span>   }<a name="line.146"></a>
-<span class="sourceLineNo">147</span>}<a name="line.147"></a>
+<span class="sourceLineNo">097</span>         return null;<a name="line.97"></a>
+<span class="sourceLineNo">098</span><a name="line.98"></a>
+<span class="sourceLineNo">099</span>      // Prevent OOM in case of DDOS<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      if (cache.size() &gt; 1000)<a name="line.100"></a>
+<span class="sourceLineNo">101</span>         cache.clear();<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>      while (true) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>         AcceptEncoding a = cache.get(s);<a name="line.104"></a>
+<span class="sourceLineNo">105</span>         if (a != null)<a name="line.105"></a>
+<span class="sourceLineNo">106</span>            return a;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>         a = new AcceptEncoding(s);<a name="line.107"></a>
+<span class="sourceLineNo">108</span>         if (nocache)<a name="line.108"></a>
+<span class="sourceLineNo">109</span>            return a;<a name="line.109"></a>
+<span class="sourceLineNo">110</span>         cache.putIfAbsent(s, a);<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      }<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   }<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>   private AcceptEncoding(String raw) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      this.typeRanges = TypeRange.parse(raw);<a name="line.115"></a>
+<span class="sourceLineNo">116</span>      this.typeRangesList = Collections.unmodifiableList(Arrays.asList(typeRanges));<a name="line.116"></a>
+<span class="sourceLineNo">117</span>   }<a name="line.117"></a>
+<span class="sourceLineNo">118</span><a name="line.118"></a>
+<span class="sourceLineNo">119</span>   /**<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    * Returns the list of the types ranges that make up this header.<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    * &lt;p&gt;<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    * The types ranges in the list are sorted by their q-value in descending order.<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    *<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    * @return An unmodifiable list of type ranges.<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    */<a name="line.125"></a>
+<span class="sourceLineNo">126</span>   public List&lt;TypeRange&gt; getTypeRanges() {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>      return typeRangesList;<a name="line.127"></a>
+<span class="sourceLineNo">128</span>   }<a name="line.128"></a>
+<span class="sourceLineNo">129</span><a name="line.129"></a>
+<span class="sourceLineNo">130</span>   /**<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    * Given a list of content codings, returns the best match for this &lt;code&gt;Accept-Encoding&lt;/code&gt; header.<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    * &lt;p&gt;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    *<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    * @param contentCodings The codings to match against.<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    */<a name="line.136"></a>
+<span class="sourceLineNo">137</span>   public int findMatch(String[] contentCodings) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span><a name="line.138"></a>
+<span class="sourceLineNo">139</span>      // Type ranges are ordered by 'q'.<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      // So we only need to search until we've found a match.<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      for (TypeRange mr : typeRanges)<a name="line.141"></a>
+<span class="sourceLineNo">142</span>         for (int i = 0; i &lt; contentCodings.length; i++)<a name="line.142"></a>
+<span class="sourceLineNo">143</span>            if (mr.matches(contentCodings[i]))<a name="line.143"></a>
+<span class="sourceLineNo">144</span>               return i;<a name="line.144"></a>
+<span class="sourceLineNo">145</span><a name="line.145"></a>
+<span class="sourceLineNo">146</span>      return -1;<a name="line.146"></a>
+<span class="sourceLineNo">147</span>   }<a name="line.147"></a>
+<span class="sourceLineNo">148</span><a name="line.148"></a>
+<span class="sourceLineNo">149</span>   @Override /* Object */<a name="line.149"></a>
+<span class="sourceLineNo">150</span>   public String toString() {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>      return StringUtils.join(typeRanges, ',');<a name="line.151"></a>
+<span class="sourceLineNo">152</span>   }<a name="line.152"></a>
+<span class="sourceLineNo">153</span>}<a name="line.153"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/29e3a9ea/content/site/apidocs/src-html/org/apache/juneau/http/ContentType.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/http/ContentType.html b/content/site/apidocs/src-html/org/apache/juneau/http/ContentType.html
index c8f423b..36dcfa2 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/http/ContentType.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/http/ContentType.html
@@ -42,60 +42,66 @@
 <span class="sourceLineNo">034</span> */<a name="line.34"></a>
 <span class="sourceLineNo">035</span>public class ContentType extends MediaType {<a name="line.35"></a>
 <span class="sourceLineNo">036</span><a name="line.36"></a>
-<span class="sourceLineNo">037</span>   private static final boolean nocache = Boolean.getBoolean("juneau.nocache");<a name="line.37"></a>
+<span class="sourceLineNo">037</span>   private static final boolean nocache = Boolean.getBoolean("juneau.http.ContentType.nocache");<a name="line.37"></a>
 <span class="sourceLineNo">038</span>   private static final ConcurrentHashMap&lt;String,ContentType&gt; cache = new ConcurrentHashMap&lt;String,ContentType&gt;();<a name="line.38"></a>
 <span class="sourceLineNo">039</span><a name="line.39"></a>
 <span class="sourceLineNo">040</span>   /**<a name="line.40"></a>
 <span class="sourceLineNo">041</span>    * Returns a parsed &lt;code&gt;Content-Type&lt;/code&gt; header.<a name="line.41"></a>
 <span class="sourceLineNo">042</span>    *<a name="line.42"></a>
 <span class="sourceLineNo">043</span>    * @param s The &lt;code&gt;Content-Type&lt;/code&gt; header string.<a name="line.43"></a>
-<span class="sourceLineNo">044</span>    * @return The parsed &lt;code&gt;Content-Type&lt;/code&gt; header.<a name="line.44"></a>
+<span class="sourceLineNo">044</span>    * @return The parsed &lt;code&gt;Content-Type&lt;/code&gt; header, or &lt;jk&gt;null&lt;/jk&gt; if the string was null.<a name="line.44"></a>
 <span class="sourceLineNo">045</span>    */<a name="line.45"></a>
 <span class="sourceLineNo">046</span>   public static ContentType forString(String s) {<a name="line.46"></a>
 <span class="sourceLineNo">047</span>      if (s == null)<a name="line.47"></a>
 <span class="sourceLineNo">048</span>         return null;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>      ContentType mt = cache.get(s);<a name="line.49"></a>
-<span class="sourceLineNo">050</span>      if (mt == null) {<a name="line.50"></a>
-<span class="sourceLineNo">051</span>         mt = new ContentType(s);<a name="line.51"></a>
-<span class="sourceLineNo">052</span>         if (nocache)<a name="line.52"></a>
-<span class="sourceLineNo">053</span>            return mt;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>         cache.putIfAbsent(s, mt);<a name="line.54"></a>
-<span class="sourceLineNo">055</span>      }<a name="line.55"></a>
-<span class="sourceLineNo">056</span>      return cache.get(s);<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   }<a name="line.57"></a>
-<span class="sourceLineNo">058</span><a name="line.58"></a>
-<span class="sourceLineNo">059</span>   private ContentType(String s) {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>      super(s);<a name="line.60"></a>
-<span class="sourceLineNo">061</span>   }<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>   /**<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    * Given a list of media types, returns the best match for this &lt;code&gt;Content-Type&lt;/code&gt; header.<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    * &lt;p&gt;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    * Note that fuzzy matching is allowed on the media types where the &lt;code&gt;Content-Types&lt;/code&gt; header may<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    * contain additional subtype parts.<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    * &lt;br&gt;For example, given a &lt;code&gt;Content-Type&lt;/code&gt; value of &lt;js&gt;"text/json+activity"&lt;/js&gt;,<a name="line.68"></a>
-<span class="sourceLineNo">069</span>    * the media type &lt;js&gt;"text/json"&lt;/js&gt; will match if &lt;js&gt;"text/json+activity"&lt;/js&gt; or &lt;js&gt;"text/activity+json"&lt;/js&gt;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    * isn't found.<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    * &lt;br&gt;The purpose for this is to allow parsers to match when artifacts such as &lt;code&gt;id&lt;/code&gt; properties are present<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    * in the header.<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    *<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    * @param mediaTypes The media types to match against.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    */<a name="line.76"></a>
-<span class="sourceLineNo">077</span>   public int findMatch(MediaType[] mediaTypes) {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>      int matchQuant = 0, matchIndex = -1;<a name="line.78"></a>
-<span class="sourceLineNo">079</span><a name="line.79"></a>
-<span class="sourceLineNo">080</span>      for (int i = 0; i &lt; mediaTypes.length; i++) {<a name="line.80"></a>
-<span class="sourceLineNo">081</span>         MediaType mt = mediaTypes[i];<a name="line.81"></a>
-<span class="sourceLineNo">082</span>         int matchQuant2 = mt.match(this);<a name="line.82"></a>
-<span class="sourceLineNo">083</span>         if (matchQuant2 &gt; matchQuant) {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>            matchIndex = i;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>         }<a name="line.85"></a>
-<span class="sourceLineNo">086</span>      }<a name="line.86"></a>
-<span class="sourceLineNo">087</span><a name="line.87"></a>
-<span class="sourceLineNo">088</span>      return matchIndex;<a name="line.88"></a>
-<span class="sourceLineNo">089</span>   }<a name="line.89"></a>
-<span class="sourceLineNo">090</span>}<a name="line.90"></a>
+<span class="sourceLineNo">049</span><a name="line.49"></a>
+<span class="sourceLineNo">050</span>      // Prevent OOM in case of DDOS<a name="line.50"></a>
+<span class="sourceLineNo">051</span>      if (cache.size() &gt; 1000)<a name="line.51"></a>
+<span class="sourceLineNo">052</span>         cache.clear();<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>      while (true) {<a name="line.54"></a>
+<span class="sourceLineNo">055</span>         ContentType mt = cache.get(s);<a name="line.55"></a>
+<span class="sourceLineNo">056</span>         if (mt != null)<a name="line.56"></a>
+<span class="sourceLineNo">057</span>            return mt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>         mt = new ContentType(s);<a name="line.58"></a>
+<span class="sourceLineNo">059</span>         if (nocache)<a name="line.59"></a>
+<span class="sourceLineNo">060</span>            return mt;<a name="line.60"></a>
+<span class="sourceLineNo">061</span>         cache.putIfAbsent(s, mt);<a name="line.61"></a>
+<span class="sourceLineNo">062</span>      }<a name="line.62"></a>
+<span class="sourceLineNo">063</span>   }<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>   private ContentType(String s) {<a name="line.65"></a>
+<span class="sourceLineNo">066</span>      super(s);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>   }<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>   /**<a name="line.69"></a>
+<span class="sourceLineNo">070</span>    * Given a list of media types, returns the best match for this &lt;code&gt;Content-Type&lt;/code&gt; header.<a name="line.70"></a>
+<span class="sourceLineNo">071</span>    * &lt;p&gt;<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    * Note that fuzzy matching is allowed on the media types where the &lt;code&gt;Content-Types&lt;/code&gt; header may<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    * contain additional subtype parts.<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    * &lt;br&gt;For example, given a &lt;code&gt;Content-Type&lt;/code&gt; value of &lt;js&gt;"text/json+activity"&lt;/js&gt;,<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    * the media type &lt;js&gt;"text/json"&lt;/js&gt; will match if &lt;js&gt;"text/json+activity"&lt;/js&gt; or &lt;js&gt;"text/activity+json"&lt;/js&gt;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    * isn't found.<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    * &lt;br&gt;The purpose for this is to allow parsers to match when artifacts such as &lt;code&gt;id&lt;/code&gt; properties are present<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    * in the header.<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    *<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    * @param mediaTypes The media types to match against.<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    * @return The index into the array of the best match, or &lt;code&gt;-1&lt;/code&gt; if no suitable matches could be found.<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    */<a name="line.82"></a>
+<span class="sourceLineNo">083</span>   public int findMatch(MediaType[] mediaTypes) {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      int matchQuant = 0, matchIndex = -1;<a name="line.84"></a>
+<span class="sourceLineNo">085</span><a name="line.85"></a>
+<span class="sourceLineNo">086</span>      for (int i = 0; i &lt; mediaTypes.length; i++) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>         MediaType mt = mediaTypes[i];<a name="line.87"></a>
+<span class="sourceLineNo">088</span>         int matchQuant2 = mt.match(this);<a name="line.88"></a>
+<span class="sourceLineNo">089</span>         if (matchQuant2 &gt; matchQuant) {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>            matchIndex = i;<a name="line.90"></a>
+<span class="sourceLineNo">091</span>         }<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      }<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>      return matchIndex;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>   }<a name="line.95"></a>
+<span class="sourceLineNo">096</span>}<a name="line.96"></a>
 
 
 



Mime
View raw message