-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #977 from coupang/optionable_request_parameter
backport #978 The tomcat parameter provides an option for the profile.
- Loading branch information
Showing
6 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ExcludeMethodFilter.java
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.navercorp.pinpoint.bootstrap.config; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ExcludeMethodFilter implements Filter<String> { | ||
private final Set<String> excludeMethods; | ||
|
||
public ExcludeMethodFilter(String excludeFormat) { | ||
this(excludeFormat, ","); | ||
} | ||
|
||
public ExcludeMethodFilter(String excludeFormat, String separator) { | ||
if (excludeFormat == null || excludeFormat.isEmpty()) { | ||
this.excludeMethods = Collections.emptySet(); | ||
return; | ||
} | ||
|
||
final String[] split = excludeFormat.split(separator); | ||
this.excludeMethods = new HashSet<String>(); | ||
for (String method : split) { | ||
if (isEmpty(method)) { | ||
continue; | ||
} | ||
method = method.trim(); | ||
if (method.isEmpty()) { | ||
continue; | ||
} | ||
excludeMethods.add(method.toUpperCase()); | ||
} | ||
} | ||
|
||
private boolean isEmpty(String string) { | ||
return string == null || string.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean filter(String value) { | ||
return excludeMethods.contains(value); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/config/ExcludeMethodFilterTest.java
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.navercorp.pinpoint.bootstrap.config; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ExcludeMethodFilterTest { | ||
|
||
@Test | ||
public void testFilter() throws Exception { | ||
Filter<String> filter = new ExcludeMethodFilter("get,post"); | ||
|
||
boolean getResult = filter.filter("GET"); | ||
boolean postResult = filter.filter("POST"); | ||
|
||
assertTrue(getResult); | ||
assertTrue(postResult); | ||
} | ||
|
||
@Test | ||
public void testUnFilter() throws Exception { | ||
Filter<String> filter = new ExcludeMethodFilter("get,post"); | ||
|
||
boolean putResult = filter.filter("PUT"); | ||
boolean headResult = filter.filter("HEAD"); | ||
|
||
assertFalse(putResult); | ||
assertFalse(headResult); | ||
} | ||
} |
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