<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 25, 2017 at 7:42 AM Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/24/2017 10:44 AM, Sebastian Laskawiec wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, May 23, 2017 at 5:06 PM Radim Vansa &lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a><br>
&gt; &lt;mailto:<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     On 05/16/2017 11:05 AM, Sebastian Laskawiec wrote:<br>
&gt;     &gt; Hey guys!<br>
&gt;     &gt;<br>
&gt;     &gt; I&#39;m working on REST Server refactoring and I changed some of the<br>
&gt;     &gt; previous behavior. Having in mind that we are implementing this in a<br>
&gt;     &gt; minor release, I tried to make those changes really cosmetic:<br>
&gt;     &gt;<br>
&gt;     &gt;   * RestEASY as well as Servlet API have been removed from<br>
&gt;     modules and<br>
&gt;     &gt;     BOM. If your app relied on it, you&#39;ll need to specify them<br>
&gt;     &gt;     separately in your pom.<br>
&gt;     &gt;   * Previous implementation picked application/text as a default<br>
&gt;     &gt;     content type. I replaced it with text/plain with charset<br>
&gt;     which is<br>
&gt;     &gt;     more precise and seems to be more widely adopted.<br>
&gt;     &gt;   * Putting an entry without any TTL nor Idle Time made it living<br>
&gt;     &gt;     forever (which was BTW aligned with the docs). I switched to<br>
&gt;     &gt;     server configured defaults in this case. If you want to have an<br>
&gt;     &gt;     entry that lives forever, just specify 0 or -1 there.<br>
&gt;     &gt;   * Requesting an entry with wrong mime type (imagine it was stored<br>
&gt;     &gt;     using application/octet-stream and now you&#39;re requesting<br>
&gt;     &gt;     text/plain) cased Bad Request. Now I switched it to Not<br>
&gt;     Acceptable<br>
&gt;     &gt;     which was designed specially to cover this type of use case.<br>
&gt;     &gt;   * In compatibility mode the server often tried to &quot;guess&quot; the<br>
&gt;     &gt;     mimetype (the decision was often between text/plain and<br>
&gt;     &gt;     application/octet-stream). I honestly think it was a wrong move<br>
&gt;     &gt;     and made the server side code very hard to read and predict what<br>
&gt;     &gt;     would be the result. Now the server always returns text/plain by<br>
&gt;     &gt;     default. If you want to get a byte stream back, just add<br>
&gt;     `Accept:<br>
&gt;     &gt;     application/octet-stream`.<br>
&gt;     &gt;   * The server can be started with port 0. This way you are 100%<br>
&gt;     sure<br>
&gt;     &gt;     that it will start using a unique port without colliding<br>
&gt;     with any<br>
&gt;     &gt;     other service.<br>
&gt;     &gt;<br>
&gt;     How can the client now the port number, then? Is the actual port<br>
&gt;     exposed<br>
&gt;     through JMX?<br>
&gt;<br>
&gt;     &gt;   * The REST server hosts HTML page if queried using GET on default<br>
&gt;     &gt;     context. I think it was a bug that it didn&#39;t work correctly<br>
&gt;     before.<br>
&gt;     &gt;<br>
&gt;     Did it return 404? What&#39;s on that page? Do we expose<br>
&gt;     keys/values/entries<br>
&gt;     anywhere in the REST endpoint?<br>
&gt;<br>
&gt;<br>
&gt; Exactly. You may try it using our Docker image and invoking something<br>
&gt; like this: curl -v -u user:changeme <a href="http://172.17.0.6:8080/rest" rel="noreferrer" target="_blank">http://172.17.0.6:8080/rest</a><br>
&gt;<br>
&gt;<br>
&gt;     &gt;   * UTF-8 charset is now the default. You may always ask the<br>
&gt;     server to<br>
&gt;     &gt;     return different encoding using Accept header. The charset<br>
&gt;     is not<br>
&gt;     &gt;     returned with binary mime types.<br>
&gt;     &gt;   * If a HEAD request results in an error, a message will be<br>
&gt;     returned<br>
&gt;     &gt;     to the client. Even though this behavior breaks Commons HTTP<br>
&gt;     &gt;     Client (HEAD requests are handled slightly differently and<br>
&gt;     causes<br>
&gt;     &gt;     the client to hang if a payload is returned), I think it&#39;s<br>
&gt;     &gt;     beneficial to tell the user what went wrong. It&#39;s worth to<br>
&gt;     mention<br>
&gt;     &gt;     that Jetty/Netty HTTP clients work correctly.<br>
&gt;     &gt;   * RestServer doesn&#39;t implement Lifecycle now. The protocol server<br>
&gt;     &gt;     doesn&#39;t support start() method without any arguments. You always<br>
&gt;     &gt;     need to specify configuration + Embedded Cache Manager.<br>
&gt;     &gt;<br>
&gt;     &gt; Even though it&#39;s a long list, I think all those changes were<br>
&gt;     worth it.<br>
&gt;     &gt; Please let me know if you don&#39;t agree.<br>
&gt;<br>
&gt;     Couple of other questions:<br>
&gt;<br>
&gt;     * do we accept GET with Range header on keys? What about<br>
&gt;     delta-updating<br>
&gt;     entries with Content-Range on PUTs?<br>
&gt;<br>
&gt;<br>
&gt; No and AFAK there are no plans to do it (but perhaps Tristan could<br>
&gt; shed some more light onto this). We could use HTTP PATCH for delta<br>
&gt; updates...<br>
&gt;<br>
&gt;     * For PUTs/POSTs, do we return 200/201/204 according to the spec?<br>
&gt;     (modified/created/modified)<br>
&gt;<br>
&gt;<br>
&gt; No, I decided to leave it as 200 for compatibility reasons. But I<br>
&gt; agree, we could change this as well.<br>
<br>
Compatibility reasons? You mean compatibility with clients not adhering<br>
to spec? (clients should accept any 2xy as success by definition).<br></blockquote><div><br></div><div>+1, created <a href="https://issues.jboss.org/browse/ISPN-7859">https://issues.jboss.org/browse/ISPN-7859</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&gt;<br>
&gt;     * Do we have any way to execute a replace (or the other prev-value<br>
&gt;     returning ops) through REST using single request? For example let<br>
&gt;     DELETE<br>
&gt;     return the prev entity (it should return 200 &amp; entity or 204 and no<br>
&gt;     response)<br>
&gt;<br>
&gt;<br>
&gt; Yes, PUT replaces previous value [1] if such exists (whereas POST<br>
&gt; would return a conflict). If for some reason you can not replace<br>
&gt; current value, you will get a preconditions failed error.<br>
<br>
I have misformulated the question. I meant to ask if there is a way to<br>
return the previous value when you&#39;ve replaced it?<br></blockquote><div><br></div><div>Unfortunately no. And there wasn&#39;t in previous REST implementation as far as I know.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
&gt;<br>
&gt; [1]<br>
&gt; <a href="https://github.com/infinispan/infinispan/pull/5094/files#diff-58f67698080cc0242320614c921559a8R301" rel="noreferrer" target="_blank">https://github.com/infinispan/infinispan/pull/5094/files#diff-58f67698080cc0242320614c921559a8R301</a><br>
<br>
Looking into the code, without considering performance at all, I think<br>
that you&#39;ve become too ecstatic about Optionals. These should be used as<br>
return types for methods, not a) parameters to methods nor b) fields.<br>
This is a misuse of the API, according to the authors of Optionals in<br>
JDK. Most of the time, you&#39;re not using optionals to have fluent chain<br>
of method invocations, so -100 to that.<br></blockquote><div><br></div><div>Answered in &quot;To Optional or not to Optional thread&quot;.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
&gt;     * Do we handle OPTIONS in any way?<br>
&gt;<br>
&gt;<br>
&gt; No. Do we need it? I haven&#39;t seen any real implementation that uses<br>
&gt; that for discovering REST operations.<br>
&gt;<br>
&gt;<br>
&gt;     Radim<br>
&gt;<br>
&gt;     &gt;<br>
&gt;     &gt; Thanks,<br>
&gt;     &gt; Sebastian<br>
&gt;     &gt;<br>
&gt;     &gt; --<br>
&gt;     &gt;<br>
&gt;     &gt; SEBASTIANŁASKAWIEC<br>
&gt;     &gt;<br>
&gt;     &gt; INFINISPAN DEVELOPER<br>
&gt;     &gt;<br>
&gt;     &gt; Red HatEMEA &lt;<a href="https://www.redhat.com/" rel="noreferrer" target="_blank">https://www.redhat.com/</a>&gt;<br>
&gt;     &gt;<br>
&gt;     &gt; &lt;<a href="https://red.ht/sig" rel="noreferrer" target="_blank">https://red.ht/sig</a>&gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; _______________________________________________<br>
&gt;     &gt; infinispan-dev mailing list<br>
&gt;     &gt; <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
&gt;     &lt;mailto:<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a>&gt;<br>
&gt;     &gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt;<br>
&gt;     --<br>
&gt;     Radim Vansa &lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a> &lt;mailto:<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;&gt;<br>
&gt;     JBoss Performance Team<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     infinispan-dev mailing list<br>
&gt;     <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a>&gt;<br>
&gt;     <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; SEBASTIANŁASKAWIEC<br>
&gt;<br>
&gt; INFINISPAN DEVELOPER<br>
&gt;<br>
&gt; Red HatEMEA &lt;<a href="https://www.redhat.com/" rel="noreferrer" target="_blank">https://www.redhat.com/</a>&gt;<br>
&gt;<br>
&gt; &lt;<a href="https://red.ht/sig" rel="noreferrer" target="_blank">https://red.ht/sig</a>&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
<br>
<br>
--<br>
Radim Vansa &lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;<br>
JBoss Performance Team<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><p class="inbox-inbox-fullname-container" style="box-sizing:border-box;color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase"><span class="inbox-inbox-firstname-container" style="box-sizing:border-box">SEBASTIAN</span><span class="inbox-inbox-Apple-converted-space"> </span><span class="inbox-inbox-lastname-container" style="box-sizing:border-box">ŁASKAWIEC</span></p><p class="inbox-inbox-position-container" style="box-sizing:border-box;color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span class="inbox-inbox-position" style="box-sizing:border-box">INFINISPAN DEVELOPER</span></p><p class="inbox-inbox-legal-container" style="box-sizing:border-box;font-family:overpass,sans-serif;margin:0px;font-size:10px;color:rgb(153,153,153)"><a class="inbox-inbox-redhat-anchor" href="https://www.redhat.com/" target="_blank" style="box-sizing:border-box;color:rgb(0,136,206);margin:0px;text-decoration:none">Red Hat<span class="inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box">EMEA</span></a></p><table border="0" style="box-sizing:border-box;color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"><td width="100px" style="box-sizing:border-box"><a href="https://red.ht/sig" style="box-sizing:border-box"><img width="90" height="auto" style="box-sizing: border-box;" src="https://www.redhat.com/files/brand/email/sig-redhat.png"></a></td></tr></tbody></table></div></div>