Skip to content

Commit

Permalink
1.0.1 - Ensure LOCK file is deleted after closing leveldb database
Browse files Browse the repository at this point in the history
  • Loading branch information
HiveGames-OSS committed Aug 30, 2024
1 parent cfd1801 commit bec3de2
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ name: Java CI with Maven

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]

jobs:
build:
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
# This workflow will build a package using Maven and then publish it to maven central

name: Publish Maven Package

on:
release:
types: [created]
types: [ created ]

jobs:
build:
Expand All @@ -22,13 +21,15 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
- name: Publish to Maven Central
run: mvn --no-transfer-progress --batch-mode deploy -s $GITHUB_WORKSPACE/settings.xml # Change to deploy when ready
env:
GITHUB_TOKEN: ${{ github.token }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
2 changes: 1 addition & 1 deletion leveldb-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
</parent>

<artifactId>leveldb-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion leveldb-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
</parent>

<artifactId>leveldb-benchmark</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion leveldb/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>leveldb-project</artifactId>
<groupId>com.hivemc.leveldb</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>leveldb</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion leveldb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
</parent>

<artifactId>leveldb</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions leveldb/src/main/java/org/iq80/leveldb/fileenv/FileLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public void release()
catch (IOException e) {
throw new DBException(e);
}
finally {
lockFile.delete();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
public class FileLockTest
{
@Test
public void testCanDeleteFileAfterUnlock() throws IOException
public void testNoLockAfterUnlock() throws IOException
{
File databaseDir = FileUtils.createTempDir("leveldb");
File lock1 = new File(databaseDir, "LOCK");
FileLock lock = FileLock.tryLock(lock1);
lock.release();
assertTrue(lock1.delete());
assertFalse(lock1.exists());
assertTrue(databaseDir.delete());
assertFalse(databaseDir.exists());
}
Expand All @@ -57,7 +57,7 @@ public void testCantDoubleLock() throws IOException
}

@Test
public void testCanDeleteFileAfterLockFailure() throws IOException
public void testNoLockAfterLockFailure() throws IOException
{
File databaseDir = FileUtils.createTempDir("leveldb");
File lock1 = new File(databaseDir, "LOCK");
Expand All @@ -70,7 +70,7 @@ public void testCanDeleteFileAfterLockFailure() throws IOException
//expected
}
lock.release();
assertTrue(lock1.delete());
assertFalse(lock1.exists());
assertTrue(databaseDir.delete());
assertFalse(databaseDir.exists());
}
Expand Down
75 changes: 62 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

<groupId>com.hivemc.leveldb</groupId>
<artifactId>leveldb-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1</version>
<packaging>pom</packaging>

<name>${project.groupId}:${project.artifactId}</name>
<description>Port of LevelDB to Java</description>
<description>Port of LevelDB to Java compatible with MCPE</description>
<url>https://github.com/HiveGamesOSS/leveldb-mcpe-java</url>

<modules>
Expand Down Expand Up @@ -96,16 +96,6 @@
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>chunker-dev</id>
<url>https://pkgs.dev.azure.com/hivetooling/Chunker/_packaging/chunker/maven/v1</url>
</repository>
<snapshotRepository>
<id>chunker-dev</id>
<url>https://pkgs.dev.azure.com/hivetooling/Chunker/_packaging/chunker/maven/v1</url>
</snapshotRepository>
</distributionManagement>

<build>
<plugins>
Expand All @@ -121,6 +111,65 @@
<repoToken>${converallstoken}</repoToken>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</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.8.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Prevent gpg from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.5.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

0 comments on commit bec3de2

Please sign in to comment.