Uploaded image for project: 'OpenShift Java Client'
  1. OpenShift Java Client
  2. OSJC-31

openshift-java-client: dont fail on unknown link-type

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 2.4.0
    • None
    • None

      When unmarshalling responses from the server there are among other objects links that shall get created. Links look like the following:

       "links":{
      "UPDATE":{
                          "href":"/domains/foobar",
                          "optional_params":[
                              
                          ],
                          "required_params":[
                              {
                                  "name":"id",
                                  "valid_options":[
                                      
                                  ],
                                  "description":"Name of the domain",
                                  "type":"string"
                              }
                          ],
                          "method":"PUT",
                          "rel":"Update domain"
                          ...
      

      The unmarshalling code currently turns the "type" property into an enum. If the type that's provided is not known, then an exception is thrown:

      public enum LinkParameterType {
      	STRING, BOOLEAN, INTEGER, ARRAY;
      	
      	public static LinkParameterType valueOfIgnoreCase(String name) throws OpenShiftRequestException {
      		if (name == null) {
      			// no type provided (this is valid, not an error)
      			return null;
      		}
      		try {
      			return	valueOf(name.toUpperCase());
      		} catch(IllegalArgumentException e) {
      			throw new OpenShiftRequestException("Unknow request parameter type {0}", name);
      		}
      	}
      

      This is not a good approach. The client library should be tolerant, it should ignore things it doesn't know to ensure it works with future responses. This is even more true as responses evolve over time even in the same protocol version: OpenShift is backporting new features (additions only) to old protocols!

            adietish@redhat.com André Dietisheim
            adietish@redhat.com André Dietisheim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: