Skip to content

Commit ee3cfd3

Browse files
Merge pull request #11 from botlify-net/dev
add: new release see changelog md
2 parents 53c9f19 + 287d98b commit ee3cfd3

File tree

3 files changed

+58
-37
lines changed

3 files changed

+58
-37
lines changed

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
Features:
2-
- Update dependencies
3-
- Lint code with two spaces
2+
- Update pom.xml with the latest version plugins
3+
- Update the dev contact to try to have a logo on the mvnrepository.com
4+
5+
Fixes:
6+
- Fix possible dead log in PropertyFieldManager class file
7+
- Add version number in three parts in the pom.xml

pom.xml

+18-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<groupId>net.botlify.dot-properties</groupId>
88
<artifactId>dot-properties</artifactId>
9-
<version>1.1</version>
9+
<version>1.1.0</version>
1010

1111
<name>Dot Properties</name>
1212
<url>https://github.com/botlify-net/dot-properties</url>
13-
<description>Manage your properties file like a pro</description>
13+
<description>Manage your properties config file with annotation.</description>
1414

1515
<properties>
1616
<maven.compiler.source>17</maven.compiler.source>
@@ -25,9 +25,9 @@
2525
</organization>
2626

2727
<scm>
28-
<connection>scm:github:https://github.com/botlify-net/dot-properties</connection>
29-
<developerConnection>scm:github:https://github.com/botlify-net/dot-properties</developerConnection>
3028
<url>https://github.com/botlify-net/dot-properties</url>
29+
<connection>scm:git:git://github.com/botlify-net/dot-properties.git</connection>
30+
<developerConnection>scm:git:[email protected]:botlify-net/dot-properties.git</developerConnection>
3131
<tag>master</tag>
3232
</scm>
3333

@@ -83,7 +83,7 @@
8383
<plugin>
8484
<groupId>org.apache.maven.plugins</groupId>
8585
<artifactId>maven-gpg-plugin</artifactId>
86-
<version>3.0.1</version>
86+
<version>3.1.0</version>
8787
<executions>
8888
<execution>
8989
<id>sign-artifacts</id>
@@ -148,7 +148,7 @@
148148
<groupId>org.projectlombok</groupId>
149149
<artifactId>lombok</artifactId>
150150
<version>1.18.30</version>
151-
<scope>provided</scope>
151+
<scope>compile</scope>
152152
</dependency>
153153
</dependencies>
154154

@@ -158,7 +158,7 @@
158158
<!-- Build the JavaDoc -->
159159
<groupId>org.apache.maven.plugins</groupId>
160160
<artifactId>maven-source-plugin</artifactId>
161-
<version>3.2.1</version>
161+
<version>3.3.0</version>
162162
<executions>
163163
<execution>
164164
<id>attach-sources</id>
@@ -173,9 +173,9 @@
173173
<plugin>
174174
<groupId>org.apache.maven.plugins</groupId>
175175
<artifactId>maven-javadoc-plugin</artifactId>
176-
<version>3.5.0</version>
176+
<version>3.6.3</version>
177177
<configuration>
178-
<source>1.8</source>
178+
<source>${maven.compiler.source}</source>
179179
<failOnError>true</failOnError>
180180
<failOnWarnings>true</failOnWarnings>
181181
</configuration>
@@ -199,8 +199,15 @@
199199
<artifactId>maven-compiler-plugin</artifactId>
200200
<version>3.11.0</version>
201201
<configuration>
202-
<source>16</source>
203-
<target>16</target>
202+
<source>${maven.compiler.source}</source>
203+
<target>${maven.compiler.target}</target>
204+
<annotationProcessorPaths>
205+
<path>
206+
<groupId>org.projectlombok</groupId>
207+
<artifactId>lombok</artifactId>
208+
<version>1.18.30</version>
209+
</path>
210+
</annotationProcessorPaths>
204211
</configuration>
205212
</plugin>
206213
</plugins>

src/main/java/net/botlify/dotproperties/fields/PropertyFieldManager.java

+34-24
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class PropertyFieldManager {
2323
private static final List<PropertyField> fields = new ArrayList<>();
2424

2525
/**
26-
* The lock used to synchronize the access to the fields list.
26+
* The lock used to synchronize the access to the field list.
2727
*/
2828
private static final ReentrantLock lock = new ReentrantLock();
2929

@@ -60,8 +60,11 @@ private PropertyFieldManager() {
6060
*/
6161
public static void addPropertyField(@NotNull final PropertyField field) {
6262
lock.lock();
63-
fields.add(field);
64-
lock.unlock();
63+
try {
64+
fields.add(field);
65+
} finally {
66+
lock.unlock();
67+
}
6568
}
6669

6770
/**
@@ -78,27 +81,30 @@ public static boolean parseField(@NotNull final Object bean,
7881
@NotNull final Field field,
7982
@NotNull final String value) throws IllegalAccessException {
8083
lock.lock();
81-
// Verify if the field is final.
82-
if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
83-
log.warn("Field {} is final, skipping updating", field.getName());
84-
return (false);
85-
}
86-
// Verify if the field is primitive.
87-
if (parsePrimitiveField(bean, field, value))
88-
return (true);
89-
for (PropertyField propertyField : fields) {
90-
if (propertyField.getType() == field.getType()) {
91-
try {
92-
field.setAccessible(true);
93-
field.set(bean, propertyField.parseString(value));
94-
return (true);
95-
} catch (IllegalAccessException e) {
96-
log.error("Unable to set field {} to value {}", field.getName(), value, e);
97-
return (false);
84+
try {
85+
// Verify if the field is final.
86+
if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
87+
log.warn("Field {} is final, skipping updating", field.getName());
88+
return (false);
89+
}
90+
// Verify if the field is primitive.
91+
if (parsePrimitiveField(bean, field, value))
92+
return (true);
93+
for (PropertyField propertyField : fields) {
94+
if (propertyField.getType() == field.getType()) {
95+
try {
96+
field.setAccessible(true);
97+
field.set(bean, propertyField.parseString(value));
98+
return (true);
99+
} catch (IllegalAccessException e) {
100+
log.error("Unable to set field {} to value {}", field.getName(), value, e);
101+
return (false);
102+
}
98103
}
99104
}
105+
} finally {
106+
lock.unlock();
100107
}
101-
lock.unlock();
102108
log.warn("Unsupported field type {} for field {}",
103109
field.getType().getName(), field.getName());
104110
return (false);
@@ -150,9 +156,13 @@ private static boolean parsePrimitiveField(@NotNull final Object bean,
150156
public static @NotNull List<Class<?>> getImplementedClassList() {
151157
List<Class<?>> classes = new ArrayList<>();
152158
lock.lock();
153-
for (PropertyField field : fields)
154-
classes.add(field.getType());
155-
lock.unlock();
159+
try {
160+
for (PropertyField field : fields) {
161+
classes.add(field.getType());
162+
}
163+
} finally {
164+
lock.unlock();
165+
}
156166
return (classes);
157167
}
158168

0 commit comments

Comments
 (0)