Skip to content

Commit

Permalink
POM changes and fix sonar smells
Browse files Browse the repository at this point in the history
  • Loading branch information
tshan10 committed Oct 10, 2024
1 parent a9c3ea9 commit 6c39b4f
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 172 deletions.
207 changes: 90 additions & 117 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

<groupId>com.phonepe</groupId>
<artifactId>DLM</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>

<url>https://github.com/PhonePe/DLM</url>
<description>Distributed Lock Manager</description>
<inceptionYear>2024</inceptionYear>

<scm>
<connection>scm:git:https://github.com/PhonePe/DLM.git</connection>
Expand Down Expand Up @@ -56,17 +57,6 @@
<url>https://travis-ci.org/PhonePe/DLM</url>
</ciManagement>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>clojars.org</id>
Expand All @@ -91,7 +81,9 @@
<maven.javadoc.plugin.version>3.3.1</maven.javadoc.plugin.version>
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
<jacoco.maven.plugin.version>0.8.7</jacoco.maven.plugin.version>
<nexus.staging.maven.plugin.version>1.6.7</nexus.staging.maven.plugin.version>
<sonatype.central.publishing.maven.plugin.version>0.5.0</sonatype.central.publishing.maven.plugin.version>
<maven.release.plugin.version>2.5.3</maven.release.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>

<!-- Test related properties -->
<mockito.version>4.3.1</mockito.version>
Expand All @@ -108,6 +100,12 @@
<sonar.projectKey>PhonePe_DLM</sonar.projectKey>
<sonar.organization>phonepe</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonar.exclusions>
<!-- Excluding test classes from sonar smells -->
**/src/test/com/phonepe/dlm/**/*.java,
**/src/test/com/phonepe/dlm/*.java
</sonar.exclusions>
</properties>

<dependencies>
Expand Down Expand Up @@ -235,6 +233,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
<configuration>
<source>${jdk.source.version}</source>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -250,119 +252,90 @@
<version>${maven.surefire.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${sonatype.central.publishing.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin.version}</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<id>release</id>
<activation>
<property>
<name>release</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.4.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
10 changes: 6 additions & 4 deletions src/main/java/com/phonepe/dlm/exception/DLMException.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Objects;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
Expand All @@ -44,10 +46,10 @@ public static DLMException propagate(final Throwable throwable) {
}

public static DLMException propagate(final String message, final Throwable throwable) {
if (throwable instanceof DLMException) {
return (DLMException) throwable;
} else if (throwable.getCause() instanceof DLMException) {
return (DLMException) throwable.getCause();
if (throwable instanceof DLMException exception) {
return exception;
} else if (throwable.getCause() instanceof DLMException causeException) {
return causeException;
}
return DLMException.builder()
.errorCode(ErrorCode.INTERNAL_ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void write(String lockId, LockLevel lockLevel, String farmId, Duration tt
final WritePolicy writePolicy = new WritePolicy(aerospikeClient.getWritePolicyDefault());
writePolicy.generationPolicy = GenerationPolicy.EXPECT_GEN_EQUAL;
writePolicy.generation = 0;
writePolicy.expiration = Long.valueOf(ttlSeconds.getSeconds()).intValue(); // as only int is supported
writePolicy.expiration = (int) ttlSeconds.getSeconds(); // as only int is supported
writePolicy.commitLevel = CommitLevel.COMMIT_MASTER; // Committing to master only, as there is no read required so there is no chance of dirty reads.
try {
final List<Bin> binList = new ArrayList<>();
Expand Down
Loading

0 comments on commit 6c39b4f

Please sign in to comment.