Uploaded image for project: 'Red Hat Data Grid'
  1. Red Hat Data Grid
  2. JDG-2227

Precondition Failed when inserting data twice using Rest

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Minor
    • Resolution: Done
    • JDG 7.3 DR1
    • JDG 7.3 GA
    • None
    • None
    • Hide

      Start the server with `./standalone.sh -Dinfinispan.deserialization.whitelist.regexps=org.infinispan.interop.*, create a Java class with a `public static void main` method and execute it twice

      Show
      Start the server with `./standalone.sh -Dinfinispan.deserialization.whitelist.regexps=org.infinispan.interop.*, create a Java class with a `public static void main` method and execute it twice
    • Hide

      When storing pojos in the cache, make sure the equals method is implemented

      Show
      When storing pojos in the cache, make sure the equals method is implemented

    Description

      Using the cache configuration

                  <cache-container name="local" default-cache="default" statistics="true">
                      <modules>
                          <module name="deployment.sample-interop-entities-1.0-SNAPSHOT.jar"/>
                      </modules>
                      <global-state/>
                      <local-cache name="default"/>
                      <local-cache name="namedCache"/>
                      <local-cache name="my-cache">
                         <encoding>
                            <key media-type="application/x-java-object"/>
                            <value media-type="application/x-java-object"/>
                         </encoding>
                      </local-cache>
                  </cache-container>
      

      With the following client:

            Executor requestExecutor = Executor.newInstance();
            String json = "{\"_type\":\"org.infinispan.interop.CryptoCurrency\",\"description\":\"Monero-"+ UUID.randomUUID().toString() +"\",\"rank\":12}";
            StatusLine status = requestExecutor.execute(
                  Request.Put(String.format("http://%s:%d/rest/%s/%s", "localhost", 8080, cacheName, key))
                        .bodyString(json, ContentType.APPLICATION_JSON))
                  .returnResponse().getStatusLine();
            if (status.getStatusCode() != 200) {
               throw new IllegalStateException(status.getReasonPhrase());
            }
      

      When calling the client twice it will fail due:

      Exception in thread "main" java.lang.IllegalStateException: Precondition Failed
      

      I search on the Internet and found the text about 412 (Precondition Failed)

      Compares the requested variant’s last modification time and date with a supplied time and date value. If the requested resources have not been modified since the supplied date and time, the specified operation is performed. If the requested resource has been modified since the supplied date and time, the operation is not performed and a 412 (Precondition Failed) response is returned.
      

      The demo code can be found in https://github.com/infinispan-demos/endpoint-interop

      If it is an issue, I would like to change the Priority from Critical to Blocker

      Attachments

        Issue Links

          Activity

            People

              gfernand@redhat.com Gustavo Fernandes (Inactive)
              dlovison@redhat.com Diego Lovison
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: