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

Precondition Failed when inserting data twice using Rest

    XMLWordPrintable

Details

    • 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
    • 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

      Also an update of an entry via REST will fail:
      curl -v -X PUT -H "Content-type:application/json" -d "

      {\"name1\":\"Wolf\"}

      " http://localhost:8080/rest/default/a

      This command will fail with a error message "412 Precondition Failed"

      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 Also an update of an entry via REST will fail: curl -v -X PUT -H "Content-type:application/json" -d " {\"name1\":\"Wolf\"} " http://localhost:8080/rest/default/a This command will fail with a error message "412 Precondition Failed"
    • JDG Sprint #25, JDG Sprint #26

    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

              anistor Adrian Nistor (Inactive)
              rhn-support-wfink Wolf Fink
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: