Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable delimiter parsing when construct from MapConfiguration #74

Merged
merged 5 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>1.8.7</version>
<version>1.8.8</version>

<name>hugegraph-common</name>
<url>https://github.com/hugegraph/hugegraph-common</url>
Expand Down Expand Up @@ -287,7 +287,7 @@
<manifestEntries>
<!-- Must be on one line, otherwise the automatic
upgrade script cannot replace the version number -->
<Implementation-Version>1.8.7.0</Implementation-Version>
<Implementation-Version>1.8.8.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/baidu/hugegraph/config/HugeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.commons.configuration.AbstractFileConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;

Expand All @@ -42,7 +43,6 @@ public HugeConfig(Configuration config) {
if (config == null) {
throw new ConfigException("The config object is null");
}

this.reloadIfNeed(config);
this.setLayoutIfNeeded(config);

Expand All @@ -59,10 +59,12 @@ public HugeConfig(String configFile) {
}

private void reloadIfNeed(Configuration conf) {
if (conf instanceof MapConfiguration) {
((MapConfiguration) conf).setDelimiterParsingDisabled(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to line 66

if (!(conf instanceof AbstractFileConfiguration)) {
return;
}

AbstractFileConfiguration fileConfig = (AbstractFileConfiguration) conf;

File file = fileConfig.getFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public class CommonVersion {

// The second parameter of Version.of() is for all-in-one JAR
public static final Version VERSION = Version.of(CommonVersion.class,
"1.8.7");
"1.8.8");
}
15 changes: 15 additions & 0 deletions src/test/java/com/baidu/hugegraph/unit/config/HugeConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -409,6 +412,18 @@ public void testSaveHugeConfig() throws ConfigurationException,
}
}

@Test
public void testFromMapConfigurationWithList() {
Map<String, String> options = new HashMap<>();
options.put(TestOptions.list.name(), "[a, b]");
MapConfiguration mapConfiguration = new MapConfiguration(options);
HugeConfig hugeConfig = new HugeConfig(mapConfiguration);
List<String> values = hugeConfig.get(TestOptions.list);
Assert.assertEquals(2, values.size());
Assert.assertTrue(values.contains("a"));
Assert.assertTrue(values.contains("b"));
}

public static class TestOptions extends OptionHolder {

private static volatile TestOptions instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void testGetImplementationVersion() throws MalformedURLException {
//Mockito.when(clazz.getResource("fake.class")).thenReturn(manifest);

String manifestPath = "file:./src/test/resources";
Assert.assertEquals("1.8.7.0",
Assert.assertEquals("1.8.8.0",
VersionUtil.getImplementationVersion(manifestPath));

manifestPath = "file:./src/test/resources2";
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Implementation-Version: 1.8.7.0
Implementation-Version: 1.8.8.0
Archiver-Version: Plexus Archiver
Built-By: jermy
Specification-Title: hugegraph-common
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_111
Specification-Version: 1.8.7
Specification-Version: 1.8.8