-
Notifications
You must be signed in to change notification settings - Fork 97
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
TASK-5888 - REST Error : 414 URI too large and 431 Header too large #2443
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,8 @@ public class Configuration { | |
|
||
private static Logger logger; | ||
|
||
private static final Set<String> reportedFields = new HashSet<>(); | ||
|
||
private static final String DEFAULT_CONFIGURATION_FORMAT = "yaml"; | ||
|
||
static { | ||
|
@@ -200,6 +202,16 @@ private static void overwriteWithEnvironmentVariables(Configuration configuratio | |
} | ||
} | ||
|
||
public static void reportUnusedField(String field, Object value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll definitely be using this method |
||
// Report only if the value is not null and not an empty string | ||
if (value != null && !(value instanceof String && ((String) value).isEmpty())) { | ||
if (reportedFields.add(field)) { | ||
// Only log the first time a field is found | ||
logger.warn("Ignored configuration option '{}' with value '{}'. The option was deprecated and removed.", field, value); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("Configuration{"); | ||
|
@@ -246,9 +258,7 @@ public String getLogFile() { | |
|
||
@Deprecated | ||
public Configuration setLogFile(String logFile) { | ||
if (logFile != null) { | ||
logger.warn("Deprecated option 'configuration.yml#logFile'"); | ||
} | ||
reportUnusedField("configuration.yml#logFile", logFile); | ||
return this; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
|
||
package org.opencb.opencga.core.config; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.opencb.opencga.core.testclassification.duration.ShortTests; | ||
|
||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.text.SimpleDateFormat; | ||
import java.util.*; | ||
|
||
/** | ||
|
@@ -34,68 +34,7 @@ | |
public class ConfigurationTest { | ||
|
||
@Test | ||
public void test() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder who left this here... |
||
String path1 = "a/b/c.txt"; | ||
String path2 = "a/b/c/"; | ||
String path3 = "p.txt"; | ||
|
||
System.out.println(path1 + " ---- " + getParentPath(path1)); | ||
System.out.println(path2 + " ---- " + getParentPath(path2)); | ||
System.out.println(path3 + " ---- " + getParentPath(path3)); | ||
|
||
System.out.println(path1 + " ---- " + calculateAllPossiblePaths(path1)); | ||
System.out.println(path2 + " ---- " + calculateAllPossiblePaths(path2)); | ||
System.out.println(path3 + " ---- " + calculateAllPossiblePaths(path3)); | ||
System.out.println("'' ---- " + calculateAllPossiblePaths("")); | ||
|
||
System.out.println(path1 + " ---- " + getFileName(path1)); | ||
System.out.println(path2 + " ---- " + getFileName(path2)); | ||
System.out.println(path3 + " ---- " + getFileName(path3)); | ||
System.out.println("'' ---- " + getFileName("")); | ||
|
||
} | ||
|
||
String getParentPath(String strPath) { | ||
Path path = Paths.get(strPath); | ||
Path parent = path.getParent(); | ||
if (parent != null) { | ||
return parent.toString() + "/"; | ||
} else { | ||
return ""; | ||
} | ||
} | ||
|
||
String getFileName(String strPath) { | ||
if (StringUtils.isEmpty(strPath)) { | ||
return "."; | ||
} | ||
return Paths.get(strPath).getFileName().toString(); | ||
} | ||
|
||
public static List<String> calculateAllPossiblePaths(String filePath) { | ||
if (StringUtils.isEmpty(filePath) || "/".equals(filePath)) { | ||
return Collections.singletonList(""); | ||
} | ||
StringBuilder pathBuilder = new StringBuilder(); | ||
String[] split = filePath.split("/"); | ||
List<String> paths = new ArrayList<>(split.length + 1); | ||
paths.add(""); //Add study root folder | ||
//Add intermediate folders | ||
//Do not add the last split, could be a file or a folder.. | ||
//Depending on this, it could end with '/' or not. | ||
for (int i = 0; i < split.length - 1; i++) { | ||
String f = split[i]; | ||
System.out.println(f); | ||
pathBuilder = new StringBuilder(pathBuilder.toString()).append(f).append("/"); | ||
paths.add(pathBuilder.toString()); | ||
} | ||
paths.add(filePath); //Add the file path | ||
return paths; | ||
} | ||
|
||
|
||
@Test | ||
public void testDefault() { | ||
public void testDefault() throws IOException { | ||
Configuration configuration = new Configuration(); | ||
|
||
configuration.setLogLevel("INFO"); | ||
|
@@ -136,7 +75,7 @@ public void testDefault() { | |
configuration.setAudit(audit); | ||
|
||
ServerConfiguration serverConfiguration = new ServerConfiguration(); | ||
RestServerConfiguration rest = new RestServerConfiguration(1000, 100, 1000); | ||
RestServerConfiguration rest = new RestServerConfiguration(1000); | ||
GrpcServerConfiguration grpc = new GrpcServerConfiguration(1001); | ||
serverConfiguration.setGrpc(grpc); | ||
serverConfiguration.setRest(rest); | ||
|
@@ -155,11 +94,10 @@ public void testDefault() { | |
// catalogConfiguration.getStorageEngines().add(storageEngineConfiguration1); | ||
// catalogConfiguration.getStorageEngines().add(storageEngineConfiguration2); | ||
|
||
try { | ||
configuration.serialize(new FileOutputStream("/tmp/configuration-test.yml")); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
Path outdir = Paths.get("target/test-data", "junit-opencga-" + | ||
new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss.SSS").format(new Date())); | ||
Files.createDirectories(outdir); | ||
configuration.serialize(Files.newOutputStream(outdir.resolve("configuration-test.yml").toFile().toPath())); | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this :)