Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dandoug committed Mar 6, 2018
1 parent 8bc75b6 commit 88249b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ The code here was ported (copied, renamed, repackaged, modified) from the [zjson

### How to use:

### Current Version : 0.4.2
### Current Version : 0.4.3

Add following to `<dependencies/>` section of your pom.xml -

```xml
<dependency>
<groupId>com.ebay.bsonpatch</groupId>
<artifactId>bsonpatch</artifactId>
<version>0.4.2</version>
<version>0.4.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ebay.bsonpatch</groupId>
<artifactId>bsonpatch</artifactId>
<version>0.4.2-SNAPSHOT</version>
<version>0.4.3</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ebay/bsonpatch/InPlaceApplyProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public void replace(List<String> path, BsonValue value) {
String fieldToReplace = path.get(path.size() - 1).replaceAll("\"", "");
if (isNullOrEmpty(fieldToReplace) && path.size() == 1)
target = value;
else if (parentNode.isDocument())
else if (parentNode.isDocument() && parentNode.asDocument().containsKey(fieldToReplace)) {
parentNode.asDocument().put(fieldToReplace, value);
else if (parentNode.isArray())
} else if (parentNode.isArray())
parentNode.asArray().set(arrayIndex(fieldToReplace, parentNode.asArray().size() - 1, false), value);
else
error(Operation.REPLACE, "noSuchPath in source, path provided : " + PathUtils.getPathRepresentation(path));
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/testdata/replace.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
{
"op": [{ "op": "replace", "path": "/x/y", "value": false }],
"node": { "x": "a" }
},
{
"op": [{ "op": "replace", "path": "non-existing-path", "value": "some-value"}],
"node": { },
"type": "BsonPatchApplicationException",
"message": "noSuchPath in source"
}
],
"ops": [
Expand Down

0 comments on commit 88249b4

Please sign in to comment.