<div dir="ltr">That would work for me. It&#39;s exactly what I did in the subclass.</div><div class="gmail_extra"><br><div class="gmail_quote">On 4 April 2016 at 16:28, Marek Posolda <span dir="ltr">&lt;<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Maybe for consistency, we can just add
      another &quot;getInstance&quot; like this:<br>
      <br>
      
      <pre style="background-color:#ffffff;color:#000000;font-family:&#39;DejaVu Sans Mono&#39;;font-size:9.0pt"><span style="color:#000080;font-weight:bold">public static </span>Keycloak getInstance(String serverUrl, String realm, String username, String password, String clientId, String clientSecret, ResteasyClient <span style="background-color:#e4e4ff">resteasyClient</span>){
    <span style="color:#000080;font-weight:bold">return new </span>Keycloak(serverUrl, realm, username, password, clientId, clientSecret, <span style="background-color:#e4e4ff">resteasyClient</span>);
}</pre><div><div class="h5">
That should be easy and not break anything regarding backwards compatibility.

Marek


On 04/04/16 15:08, Guus der Kinderen wrote:
</div></div></div><div><div class="h5"><blockquote type="cite"><div dir="ltr">Thanks for the suggestion, but wouldn&#39;t that bypass the TokenManager?<div>
</div><div>I&#39;ve just ran a quick test with subclassing Keycloak to add another getInstance(). That works fine. </div><div>
</div><div>Why not make that constructor public? Do we want to hide the Resteasy instance so bad?</div><div>
</div><div> - Guus</div></div><div class="gmail_extra">
<div class="gmail_quote">On 4 April 2016 at 15:59, Bill Burke <span dir="ltr">&lt;<a href="mailto:bburke@redhat.com" target="_blank">bburke@redhat.com</a>&gt;</span> wrote:
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    You can just create the ResteasyClient, get a ResteasyWebTarget,
    then call target.proxy(RealmsResource.class)<div><div>

    

    <div>On 4/4/2016 8:52 AM, Guus der Kinderen
      wrote:

    </div>
    <blockquote type="cite">
      <div dir="ltr">Hey, thanks for this. Coincidentally, I was looking
        into similar issues.
        <div>

        </div>
        <div>We&#39;ve been running into concurrently-related issues. These
          find their origin in the Resteasy client that is created in
          the client admin Keycloak class.</div>
        <div>

        </div>
        <div>Marek writes that the underlying connection pool can be
          modified, but that&#39;s not really straightforward: there is no
          getInstance() method that exposes the Resteasy client. One has
          to subclass the Keycloak class to gain access. Perhaps there&#39;s
          room for improvement here?</div>
        <div>

        </div>
        <div>Also, by default, the Resteasy client uses one connection.
          That seems to be a very conservative default, given the nature
          of the client admin. I believe that the client admin would
          benefit from using a thread pool of a size that&#39;s arbitrarily
          larger than 1. I&#39;d go with 10.</div>
        <div>

        </div>
        <div>Regards,</div>
        <div>

        </div>
        <div>  Guus</div>
      </div>
      <div class="gmail_extra">

        <div class="gmail_quote">On 31 March 2016 at 21:20, Hristo
          Stoyanov <span dir="ltr">&lt;<a href="mailto:hr.stoyanov@peruncs.com" target="_blank">hr.stoyanov@peruncs.com</a>&gt;</span>
          wrote:

          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <p dir="ltr">Marek,

              Thanks for this clarification and all your help in this
              forum to my other questions!</p>
            <p dir="ltr">You guys rock!</p>
            <span><font color="#888888">
                <p dir="ltr">/Hristo Stoyanov</p>
              </font></span>
            <div>
              <div>
                <div class="gmail_quote">On Mar 31, 2016 2:38 AM, &quot;Marek
                  Posolda&quot; &lt;<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;
                  wrote:

                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div bgcolor="#FFFFFF" text="#000000">
                      <div>It&#39;s supposed to be and we even internally
                        using it in some concurrency test. 

                        

                        It&#39;s using Apache HTTP client under the hood,
                        which itself is thread-safe and is using
                        connection pooling. In case you need, you can
                        configure more fine-grained details (like
                        connection pool size etc) by pass the custom
                        resteasyClient to Keycloak object.

                        

                        However when I looked a bit more into sources
                        now, I can see that there are some potential
                        concurrency issues in TokenManager class, which
                        is used internally by admin client. Created JIRA
                        <a href="https://issues.jboss.org/browse/KEYCLOAK-2731" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-2731</a>
                        for it. It&#39;s not too bad IMO, but note that you
                        can possibly see situation when more concurrent
                        threads are trying to refresh the same access
                        token at the same time.

                        

                        Marek

                        

                        

                        On 31/03/16 01:37, Hristo Stoyanov wrote:

                      </div>
                      <blockquote type="cite">
                        <p dir="ltr">Is
                          org.Keycloak.admin.client.Keycloak threadsafe?
                          I intend to use it as a single admin client
                          for the entire app ...</p>
                        <p dir="ltr">/Hristo Stoyanov</p>
                        

                        <fieldset></fieldset>
                        

                        <pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
                      </blockquote>
                      

                    </div>
                  </blockquote>
                </div>
              </div>
            </div>
            

            _______________________________________________

            keycloak-user mailing list

            <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>

            <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a>

          </blockquote>
        </div>
        

      </div>
      

      <fieldset></fieldset>
      

      <pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
    </blockquote>
    

    </div></div><span><font color="#888888"><pre cols="72">-- 
Bill Burke
JBoss, a division of Red Hat
<a href="http://bill.burkecentral.com" target="_blank">http://bill.burkecentral.com</a></pre>
  </font></span></div>


_______________________________________________

keycloak-user mailing list

<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>

<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a>
</blockquote></div>
</div>


<fieldset></fieldset>
<pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>

</blockquote>
</div></div></div></blockquote></div><br></div>