Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/snyk-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:

- name: Upload result to GitHub Code Scanning
if: steps.out-file.outputs.exists == 'true'
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: snyk.sarif
24 changes: 18 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<aerospike-client-jdk8.version>9.2.0</aerospike-client-jdk8.version>
<antlr.version>4.13.2</antlr.version>
<lombok.version>1.18.42</lombok.version>
<junit-jupiter.version>5.14.0</junit-jupiter.version>
<assertj-core.version>3.27.6</assertj-core.version>
<central.publishing.maven.plugin>0.8.0</central.publishing.maven.plugin>
<gnu.crypto.version>2.0.1</gnu.crypto.version>
<slf4j-simple.version>2.0.17</slf4j-simple.version>
</properties>

<licenses>
Expand Down Expand Up @@ -62,11 +63,6 @@
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-client-jdk8</artifactId>
<version>${aerospike-client-jdk8.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
Expand All @@ -77,6 +73,22 @@
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.gnu</groupId>
<artifactId>gnu-crypto</artifactId>
<version>${gnu.crypto.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j-simple.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-simple.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/aerospike/dsl/Index.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.aerospike.dsl;

import com.aerospike.client.cdt.CTX;
import com.aerospike.client.query.IndexCollectionType;
import com.aerospike.client.query.IndexType;
import com.aerospike.dsl.client.cdt.CTX;
import com.aerospike.dsl.client.query.IndexCollectionType;
import com.aerospike.dsl.client.query.IndexType;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/aerospike/dsl/IndexContext.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package com.aerospike.dsl;

import com.aerospike.client.query.Filter;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collection;

/**
* This class stores namespace and indexes required to build secondary index {@link Filter}
* This class stores namespace and indexes required to build secondary index Filter
*/
@AllArgsConstructor(staticName = "of")
@Getter
public class IndexContext {

/**
* Namespace to be used for creating {@link Filter}. Is matched with namespace of indexes
* Namespace to be used for creating secondary index Filter. Is matched with namespace of indexes
*/
private String namespace;
/**
* Collection of {@link Index} objects to be used for creating {@link Filter}.
* Collection of {@link Index} objects to be used for creating secondary index Filter.
* Namespace of indexes is matched with the given {@link #namespace}, bin name and index type are matched
* with bins in DSL String
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/aerospike/dsl/ParseResult.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.aerospike.dsl;

import com.aerospike.client.exp.Exp;
import com.aerospike.client.query.Filter;
import com.aerospike.dsl.client.exp.Exp;
import com.aerospike.dsl.client.query.Filter;
import lombok.AllArgsConstructor;
import lombok.Getter;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/aerospike/dsl/ParsedExpression.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.aerospike.dsl;

import com.aerospike.client.exp.Exp;
import com.aerospike.client.query.Filter;
import com.aerospike.dsl.annotation.Beta;
import com.aerospike.dsl.client.exp.Exp;
import com.aerospike.dsl.client.query.Filter;
import com.aerospike.dsl.parts.AbstractPart;
import com.aerospike.dsl.parts.ExpressionContainer;
import lombok.Getter;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/aerospike/dsl/api/DSLParser.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.aerospike.dsl.api;

import com.aerospike.client.cdt.CTX;
import com.aerospike.client.query.Filter;
import com.aerospike.dsl.DslParseException;
import com.aerospike.dsl.ExpressionContext;
import com.aerospike.dsl.Index;
import com.aerospike.dsl.IndexContext;
import com.aerospike.dsl.ParsedExpression;
import com.aerospike.dsl.client.cdt.CTX;
import com.aerospike.dsl.client.query.Filter;

/**
* Contains API to convert dot separated String path into an Aerospike filter -
Expand Down
170 changes: 170 additions & 0 deletions src/main/java/com/aerospike/dsl/client/AerospikeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Copyright 2012-2025 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.aerospike.dsl.client;

import java.util.List;

/**
* Aerospike exceptions that can be thrown from the client.
*/
public class AerospikeException extends RuntimeException {
private static final long serialVersionUID = 1L;

protected List<AerospikeException> subExceptions;
protected int resultCode = ResultCode.CLIENT_ERROR;
protected int iteration = -1;
protected boolean inDoubt;

public AerospikeException(int resultCode, String message) {
super(message);
this.resultCode = resultCode;
}

public AerospikeException(int resultCode, Throwable e) {
super(e);
this.resultCode = resultCode;
}

public AerospikeException(int resultCode) {
super();
this.resultCode = resultCode;
}

public AerospikeException(int resultCode, boolean inDoubt) {
super();
this.resultCode = resultCode;
this.inDoubt = inDoubt;
}

public AerospikeException(int resultCode, String message, Throwable e) {
super(message, e);
this.resultCode = resultCode;
}

public AerospikeException(String message, Throwable e) {
super(message, e);
}

public AerospikeException(String message) {
super(message);
}

public AerospikeException(Throwable e) {
super(e);
}

/**
* Exception thrown when a Java serialization error occurs.
*/
public static final class Serialize extends AerospikeException {
private static final long serialVersionUID = 1L;

public Serialize(Throwable e) {
super(ResultCode.SERIALIZE_ERROR, "Serialize error", e);
}

public Serialize(String message) {
super(ResultCode.SERIALIZE_ERROR, message);
}
}

/**
* Exception thrown when client can't parse data returned from server.
*/
public static final class Parse extends AerospikeException {
private static final long serialVersionUID = 1L;

public Parse(String message) {
super(ResultCode.PARSE_ERROR, message);
}
}

/**
* Return base message without extra metadata.
*/
public String getBaseMessage() {
String message = super.getMessage();
return (message != null)? message : ResultCode.getResultString(resultCode);
}

/**
* Should connection be put back into pool.
*/
public final boolean keepConnection() {
return ResultCode.keepConnection(resultCode);
}

/**
* Get sub exceptions. Will be null if a retry did not occur.
*/
public final List<AerospikeException> getSubExceptions() {
return subExceptions;
}

/**
* Set sub exceptions.
*/
public final void setSubExceptions(List<AerospikeException> subExceptions) {
this.subExceptions = subExceptions;
}

/**
* Get integer result code.
*/
public final int getResultCode() {
return resultCode;
}

/**
* Get number of attempts before failing.
*/
public final int getIteration() {
return iteration;
}

/**
* Set number of attempts before failing.
*/
public final void setIteration(int iteration) {
this.iteration = iteration;
}

/**
* Is it possible that write command may have completed.
*/
public final boolean getInDoubt() {
return inDoubt;
}

/**
* Set whether it is possible that the write command may have completed
* even though this exception was generated. This may be the case when a
* client error occurs (like timeout) after the command was sent to the server.
*/
public final void setInDoubt(boolean isWrite, int commandSentCounter) {
if (isWrite && (commandSentCounter > 1 || (commandSentCounter == 1 && (resultCode == ResultCode.TIMEOUT || resultCode <= 0)))) {
this.inDoubt = true;
}
}

/**
* Sets the inDoubt value to inDoubt.
*/
public void setInDoubt(boolean inDoubt) {
this.inDoubt = inDoubt;
}
}
Loading
Loading