[ 
https://issues.apache.org/jira/browse/OLINGO-1188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

rakhi kumari updated OLINGO-1188:
---------------------------------
    Description: 
*I am doing batch call. This is my payload:*
--batch_8659-5318-e90f
Content-Type: multipart/mixed;boundary=changeset_abc

--changeset_abc
Content-Type: application/http 
Content-Transfer-Encoding: binary
{color:red}Content-Id:1{color}
POST Manufacturers HTTP/1.1
Content-Type: application/json
{
        "Id":"3",
        "Name":"Rakhi Manufacturers"
}
--changeset_abc--
--batch_8659-5318-e90f--

*In backend these functions are being called:*
@Override
  public BatchResponsePart executeChangeSet(final BatchHandler handler, final 
List<ODataRequest> requests)
      throws ODataException {  
          List<ODataResponse> responses = new ArrayList<ODataResponse>();
                        for (ODataRequest request : requests) {
                                ODataResponse response = 
handler.handleRequest(request);
                                if (response.getStatus().getStatusCode() >= 
HttpStatusCodes.BAD_REQUEST
                                                .getStatusCode()) {

                                        List<ODataResponse> errorResponses = 
new ArrayList<ODataResponse>(1);
                                        errorResponses.add(response);
                                        return 
BatchResponsePart.responses(errorResponses).changeSet(false).build();
                                }
                                responses.add(response);
                        }

                        return 
BatchResponsePart.responses(responses).changeSet(true).build();
                
  }

public Map<String, Object> createManufacturer(int id, String name, Map<String, 
Object> address, Calendar updated) {  
    Map<String, Object> data = new HashMap<String, Object>();
  {color:#d04437}  int k =  5/0 + 6; //This I have done intentionally.{color}
    data.put("Id", id);
    data.put("Name", name);
    data.put("Address", address);
    data.put("Updated", updated);
    return data;          
  }

*Here createManufacturer function throws "Arithmetic divide by 0 exception". 
But before coming to the executeChangeSet function, in between it hits 
fillContentIdMap function which is like 
*
private void fillContentIdMap(final ODataResponse response, final String 
contentId, final String baseUri) {
    String location = response.getHeader(HttpHeaders.LOCATION);
   {color:#d04437} String relLocation = location.replace(baseUri + "/", ""); // 
here it gives nullpointer exception because location is null{color}
    contentIdMap.put("$" + contentId, relLocation);
  }

*fillContentIdMap function is in BatchHandlerImpl class
Hence, in executeChangeSet function, nullpointer exception comes instead of 
actual exception which was "Arithmetic divide by 0 Exception".
*
*If we remove content-Id from payload, It throws proper exception which is 
"Arithmetic divide by 0 Exception".*
*
How can i resolve this issue because content-id is required in our case and we 
are not able to get the proper exception at the frontend side.*

  was:
I am doing batch call. This is my payload:
--batch_8659-5318-e90f
Content-Type: multipart/mixed;boundary=changeset_abc

--changeset_abc
Content-Type: application/http 
Content-Transfer-Encoding: binary
Content-Id:1
POST Manufacturers HTTP/1.1
Content-Type: application/json
{
        "Id":"3",
        "Name":"Rakhi Manufacturers"
}
--changeset_abc--
--batch_8659-5318-e90f--

In backend these functions are being called:
@Override
  public BatchResponsePart executeChangeSet(final BatchHandler handler, final 
List<ODataRequest> requests)
      throws ODataException {  
          List<ODataResponse> responses = new ArrayList<ODataResponse>();
                        for (ODataRequest request : requests) {
                                ODataResponse response = 
handler.handleRequest(request);
                                if (response.getStatus().getStatusCode() >= 
HttpStatusCodes.BAD_REQUEST
                                                .getStatusCode()) {

                                        List<ODataResponse> errorResponses = 
new ArrayList<ODataResponse>(1);
                                        errorResponses.add(response);
                                        return 
BatchResponsePart.responses(errorResponses).changeSet(false).build();
                                }
                                responses.add(response);
                        }

                        return 
BatchResponsePart.responses(responses).changeSet(true).build();
                
  }

public Map<String, Object> createManufacturer(int id, String name, Map<String, 
Object> address, Calendar updated) {  
    Map<String, Object> data = new HashMap<String, Object>();
    int k =  5/0 + 6; //This I have done intentionally.
    data.put("Id", id);
    data.put("Name", name);
    data.put("Address", address);
    data.put("Updated", updated);
    return data;          
  }

Here createManufacturer function throws "Arithmetic divide by 0 exception". But 
before coming to the executeChangeSet function, in between it hits 
fillContentIdMap function which is like 
private void fillContentIdMap(final ODataResponse response, final String 
contentId, final String baseUri) {
    String location = response.getHeader(HttpHeaders.LOCATION);
    String relLocation = location.replace(baseUri + "/", ""); // here it gives 
nullpointer exception because location is null
    contentIdMap.put("$" + contentId, relLocation);
  }
fillContentIdMap function is in BatchHandlerImpl class
Hence, in executeChangeSet function, nullpointer exception comes instead of 
actual exception which was "Arithmetic divide by 0 Exception".

If we remove content-Id from payload, It throws proper exception which is 
"Arithmetic divide by 0 Exception".


> Having problem in "Batch Processing using changeset" regarding Content-Id
> -------------------------------------------------------------------------
>
>                 Key: OLINGO-1188
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1188
>             Project: Olingo
>          Issue Type: Question
>          Components: MISC
>            Reporter: rakhi kumari
>
> *I am doing batch call. This is my payload:*
> --batch_8659-5318-e90f
> Content-Type: multipart/mixed;boundary=changeset_abc
> --changeset_abc
> Content-Type: application/http 
> Content-Transfer-Encoding: binary
> {color:red}Content-Id:1{color}
> POST Manufacturers HTTP/1.1
> Content-Type: application/json
> {
>       "Id":"3",
>       "Name":"Rakhi Manufacturers"
> }
> --changeset_abc--
> --batch_8659-5318-e90f--
> *In backend these functions are being called:*
> @Override
>   public BatchResponsePart executeChangeSet(final BatchHandler handler, final 
> List<ODataRequest> requests)
>       throws ODataException {  
>         List<ODataResponse> responses = new ArrayList<ODataResponse>();
>                       for (ODataRequest request : requests) {
>                               ODataResponse response = 
> handler.handleRequest(request);
>                               if (response.getStatus().getStatusCode() >= 
> HttpStatusCodes.BAD_REQUEST
>                                               .getStatusCode()) {
>                                       List<ODataResponse> errorResponses = 
> new ArrayList<ODataResponse>(1);
>                                       errorResponses.add(response);
>                                       return 
> BatchResponsePart.responses(errorResponses).changeSet(false).build();
>                               }
>                               responses.add(response);
>                       }
>                       return 
> BatchResponsePart.responses(responses).changeSet(true).build();
>               
>   }
> public Map<String, Object> createManufacturer(int id, String name, 
> Map<String, Object> address, Calendar updated) {  
>     Map<String, Object> data = new HashMap<String, Object>();
>   {color:#d04437}  int k =  5/0 + 6; //This I have done intentionally.{color}
>     data.put("Id", id);
>     data.put("Name", name);
>     data.put("Address", address);
>     data.put("Updated", updated);
>     return data;        
>   }
> *Here createManufacturer function throws "Arithmetic divide by 0 exception". 
> But before coming to the executeChangeSet function, in between it hits 
> fillContentIdMap function which is like 
> *
> private void fillContentIdMap(final ODataResponse response, final String 
> contentId, final String baseUri) {
>     String location = response.getHeader(HttpHeaders.LOCATION);
>    {color:#d04437} String relLocation = location.replace(baseUri + "/", ""); 
> // here it gives nullpointer exception because location is null{color}
>     contentIdMap.put("$" + contentId, relLocation);
>   }
> *fillContentIdMap function is in BatchHandlerImpl class
> Hence, in executeChangeSet function, nullpointer exception comes instead of 
> actual exception which was "Arithmetic divide by 0 Exception".
> *
> *If we remove content-Id from payload, It throws proper exception which is 
> "Arithmetic divide by 0 Exception".*
> *
> How can i resolve this issue because content-id is required in our case and 
> we are not able to get the proper exception at the frontend side.*



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to