Skip to content

Commit

Permalink
Merge pull request #29 from congcoi123/develop
Browse files Browse the repository at this point in the history
Release 0.5.0.230830
  • Loading branch information
congcoi123 committed Aug 30, 2023
2 parents 12fc9d2 + f1d2ae1 commit 4867f40
Show file tree
Hide file tree
Showing 53 changed files with 1,486 additions and 692 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Run all unit test cases and verify the GPG key
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@

## 0.4.0 2022-11-20 Feature release
- Moved annotations management to the [tenio-core](https://github.com/congcoi123/tenio-core) module

## 0.5.0 2023-08-30 Feature release
- Upgraded to JDK 17
- Upgraded dependencies
- Allowed checking logging configuration before writing logs
- Added some utility methods to work with custom data types
- Changed some methods' names
- Fixed test cases' issues
- Bugs fixed
6 changes: 3 additions & 3 deletions CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
- [x] Executes command *mvn clean install* to run the *checkstyle* process

### Before updating to new version
- [x] Makes sure the current branch is *develop* branch
- [x] Makes sure the current branch is *develop* branch
- [x] Creates a Pull Request (PR) from develop to master branch
- [x] All new methods should be annotated by the *@since* annotation
- [x] Changes version in *pom.xml* file
- [x] Updates new changes in the *CHANGELOG.md* file
- [x] Updates the *VERSION* file
- [x] Updates the *README.md* file
- [x] Executes command *mvn clean install* to run the *checkstyle* process
- [x] Creates a Pull Request (PR) from develop to master branch
- [x] Executes command *mvn clean install* to run the *checkstyle* process

### Creating a new release
- [x] Makes sure the current branch is *master* branch
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<a href="CONTRIBUTING.md">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
</a>
<a href="https://gitter.im/ten-io/community?source=orgpage">
<img src="https://badges.gitter.im/Join%20Chat.svg">
<a href="https://discord.gg/MGCxEwUR">
<img src="https://img.shields.io/discord/1146091189456613407">
</a>
</p>

Expand All @@ -41,7 +41,7 @@ This module provides common methods, classes for other modules to use. It suppor
mechanism and supplies the self-defined serialized and deserialized processes for transferring data through the network.

## Requirements
- Java 11
- Java 17

## License
The [`TenIO`](https://github.com/congcoi123/tenio) project is currently available under the [MIT](LICENSE) License.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20221120.0.4.0
20230830.0.5.0
27 changes: 17 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.congcoi123</groupId>
<artifactId>tenio-common</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -41,28 +41,28 @@
<properties>
<google.guava.version>31.1-jre</google.guava.version>
<org.msgpack.version>0.6.12</org.msgpack.version>
<logging.log4j.version>2.17.2</logging.log4j.version>
<logging.log4j.version>2.20.0</logging.log4j.version>
<org.reflections.version>0.10.2</org.reflections.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<org.junit.jupiter.version>5.8.2</org.junit.jupiter.version>
<org.junit.platform.version>1.8.2</org.junit.platform.version>
<org.mockito.core.version>4.4.0</org.mockito.core.version>
<org.junit.jupiter.version>5.9.2</org.junit.jupiter.version>
<org.junit.platform.version>1.9.2</org.junit.platform.version>
<org.mockito.core.version>5.2.0</org.mockito.core.version>

<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<jdk.release>11</jdk.release>
<jdk.vendor>oracle</jdk.vendor>

<maven.checkstyle.version>3.1.2</maven.checkstyle.version>
<maven.source.plugin.version>3.2.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>3.2.0</maven.javadoc.plugin.version>
<maven.javadoc.plugin.version>3.5.0</maven.javadoc.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<jacoco.maven.plugin.version>0.8.7</jacoco.maven.plugin.version>
<coveralls.maven.plugin.version>4.3.0</coveralls.maven.plugin.version>

<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>

<dependencies>
Expand Down Expand Up @@ -147,6 +147,12 @@
<version>${org.mockito.core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
<type>maven-plugin</type>
</dependency>
</dependencies>

<distributionManagement>
Expand Down Expand Up @@ -233,18 +239,19 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
<!-- for java 8 compatible -->
<executions>
<execution>
<id>attach-javadocs</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
<!-- for java 11 compatible -->
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<detectJavaApiLink>false</detectJavaApiLink>
</configuration>
</plugin>
<!-- Sign artifacts for uploading to maven central -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ protected void push(ConfigurationType key, Object value) {
}

if (configuration.containsKey(key)) {
info("CONFIGURATION",
buildgen("Configuration key [", key, "] attempted to replace the old value ",
configuration.get(key), " by the new one ", value));
if (isInfoEnabled()) {
info("CONFIGURATION",
buildgen("Configuration key [", key, "] attempted to replace the old value ",
configuration.get(key), " by the new one ", value));
}
return;
}

Expand Down
15 changes: 4 additions & 11 deletions src/main/java/com/tenio/common/data/DataUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,9 @@ public static MsgPackMap newMsgMap() {
* @return a new collection instance
*/
public static DataCollection binaryToCollection(DataType type, byte[] binary) {
switch (type) {
case ZERO:
return ZeroUtility.binaryToCollection(binary);

case MSG_PACK:
return MsgPackUtility.deserialize(binary);

default:
throw new UnsupportedOperationException(String.format("Unsupported serialization type: " +
"%s", type));
}
return switch (type) {
case ZERO -> ZeroUtility.binaryToCollection(binary);
case MSG_PACK -> MsgPackUtility.deserialize(binary);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Serial;
import java.io.Serializable;

/**
* @author Riyad Kalla (software@thebuzzmedia.com)
*/
public final class ByteArrayInputStream extends InputStream implements Serializable {

@Serial
private static final long serialVersionUID = -5334077014767018880L;

private int offset;
Expand Down
63 changes: 30 additions & 33 deletions src/main/java/com/tenio/common/data/msgpack/MsgPackUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class MsgPackUtility {

private MsgPackUtility() {
throw new UnsupportedOperationException("This class does not support creating a new instance");
}

/**
* Serialize an object to an array of bytes data.
*
Expand All @@ -55,31 +59,6 @@ public static byte[] serialize(MsgPackMap msgPackMap) {
return MsgPackConverter.pack(msgPackMap);
}

/**
* Deserialize an array of bytes data to a {@link MsgPackMap} object.
*
* @param msgPackMap the message container which is using in the system
* @param byteArrayInput the object for converting raw binaries' data to msgpack
* using one
* @param binaries an array of bytes data
* @return an message object in {@link MsgPackMap} type
*/
public static MsgPackMap deserialize(MsgPackMap msgPackMap, ByteArrayInputStream byteArrayInput,
byte[] binaries) {
var dstMap = MsgPackConverter.unpack(byteArrayInput, binaries);
if (dstMap == null || dstMap.isEmpty()) {
return null;
}
dstMap.forEach((key, value) -> {
try {
msgPackMap.put(key, MsgPackConverter.valueToObject(value));
} catch (IOException e) {
e.printStackTrace();
}
});
return msgPackMap;
}

/**
* Deserialize an array of bytes data to a {@link MsgPackMap} object.
*
Expand All @@ -96,12 +75,30 @@ public static MsgPackMap deserialize(byte[] binaries) {
dstMap.forEach((key, value) -> {
try {
msgObject.put(key, MsgPackConverter.valueToObject(value));
} catch (IOException e) {
e.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
}
});
return msgObject;
}

/**
* Retrieves new instance of the {@link MsgPackMap} class.
*
* @return an instance
*/
public static MsgPackMap newMsgPackMap() {
return MsgPackMap.newInstance();
}

/**
* Retrieves new instance of the {@link MsgPackArray} class.
*
* @return an instance
*/
public static MsgPackArray newMsgPackArray() {
return MsgPackArray.newInstance();
}
}

class MsgPackConverter {
Expand All @@ -120,8 +117,8 @@ class MsgPackConverter {
public static byte[] pack(Map<String, Object> map) {
try {
return PACKER.write(map);
} catch (IOException e) {
e.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
return null;
}
}
Expand All @@ -139,8 +136,8 @@ public static Map<String, Value> unpack(ByteArrayInputStream byteArrayInput, byt
byteArrayInput.reset(binaries);
var unpacker = PACKER.createUnpacker(byteArrayInput);
return unpacker.read(mapTmpl);
} catch (IOException | IllegalArgumentException e) {
e.printStackTrace();
} catch (IOException | IllegalArgumentException exception) {
exception.printStackTrace();
return null;
}
}
Expand Down Expand Up @@ -172,8 +169,8 @@ public static Object valueToObject(Value value) throws IOException {
arrayValue.forEach(element -> {
try {
array.add(valueToObject(element));
} catch (IOException e) {
e.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
}
});
return array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal

package com.tenio.common.data.msgpack.element;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -34,6 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class MsgPackArray extends ArrayList<Object> implements Serializable {

@Serial
private static final long serialVersionUID = -2718756636745901607L;

/**
Expand Down

0 comments on commit 4867f40

Please sign in to comment.