Skip to content

Commit a39b07d

Browse files
committed
Improved arrays validation
1 parent 7d3ff09 commit a39b07d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README.MD

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ maven {
2020
url = 'https://repo.mikigal.pl/releases'
2121
}
2222
23-
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.3'
23+
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.4'
2424
```
2525

2626
#### Maven
@@ -33,7 +33,7 @@ compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.1.3'
3333
<dependency>
3434
<groupId>pl.mikigal</groupId>
3535
<artifactId>ConfigAPI</artifactId>
36-
<version>1.1.3</version>
36+
<version>1.1.4</version>
3737
<scope>compile</scope>
3838
</dependency>
3939
```

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'pl.mikigal'
7-
version '1.1.3'
7+
version '1.1.4'
88

99
publishing {
1010
repositories {

src/main/java/pl/mikigal/config/BukkitConfiguration.java

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public void set(String path, Object value, Comment comment) {
7171

7272
@Override
7373
public void set(String path, Object value) {
74+
if (value != null && value.getClass().isArray()) {
75+
throw new InvalidConfigException("Arrays are not supported, use Collection instead");
76+
}
77+
7478
if (!(value instanceof Collection) && !(value instanceof Map) && (value == null || TypeUtils.isSimpleType(value))) {
7579
super.set(path, value);
7680

src/main/java/pl/mikigal/config/ConfigInvocationHandler.java

+8
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ private void prepareMethods() {
160160
continue;
161161
}
162162

163+
if (method.getReturnType().isArray()) {
164+
throw new InvalidConfigException("Arrays are not supported, use Collection instead");
165+
}
166+
163167
if (!method.isDefault()) {
164168
throw new InvalidConfigException("Getter method " + name + " has not default value");
165169
}
@@ -182,6 +186,10 @@ private void prepareMethods() {
182186
continue;
183187
}
184188

189+
if (method.getReturnType().isArray()) {
190+
throw new InvalidConfigException("Arrays are not supported, use Collection instead");
191+
}
192+
185193
if (method.isDefault()) {
186194
throw new InvalidConfigException("Setter method " + name + " has default value");
187195
}

0 commit comments

Comments
 (0)