Skip to content

Commit d42b4ec

Browse files
committed
refactor: normalize locale handling
1 parent be1008a commit d42b4ec

9 files changed

Lines changed: 13 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ jobs:
2727
distribution: temurin
2828
java-version: ${{ matrix.java }}
2929
cache: maven
30-
- name: Verify source comment policy
31-
shell: pwsh
32-
run: powershell -NoProfile -ExecutionPolicy Bypass -File tools/check-no-comments.ps1
3330
- name: Verify unit and attach integration tests
3431
run: mvn --batch-mode --no-transfer-progress verify
3532
- uses: actions/upload-artifact@v4

.github/workflows/release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ jobs:
5151
"JPI_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
5252
"Validated JPI version $version" | Add-Content $env:GITHUB_STEP_SUMMARY
5353
54-
- name: Verify source comment policy
55-
shell: pwsh
56-
run: powershell -NoProfile -ExecutionPolicy Bypass -File tools/check-no-comments.ps1
57-
5854
- name: Run unit and attach integration tests
5955
run: mvn --batch-mode --no-transfer-progress clean verify
6056

src/main/java/dev/whitedev/jpi/attach/AttachService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.security.MessageDigest;
2121
import java.util.ArrayList;
2222
import java.util.List;
23+
import java.util.Locale;
2324
import java.util.UUID;
2425

2526
public final class AttachService {
@@ -71,7 +72,7 @@ public InspectorSession attach(JvmDescriptor target) throws Exception {
7172
public LaunchResult launch(File targetJar, List<String> vmArguments,
7273
List<String> applicationArguments) throws Exception {
7374
File canonicalTarget = targetJar.getCanonicalFile();
74-
if (!canonicalTarget.isFile() || !canonicalTarget.getName().toLowerCase().endsWith(".jar")) {
75+
if (!canonicalTarget.isFile() || !canonicalTarget.getName().toLowerCase(Locale.ROOT).endsWith(".jar")) {
7576
throw new IOException("Select an existing executable JAR");
7677
}
7778
File agentJar = applicationJar();

src/main/java/dev/whitedev/jpi/decompile/DecompilerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.ArrayList;
1111
import java.util.EnumMap;
1212
import java.util.List;
13+
import java.util.Locale;
1314
import java.util.Map;
1415

1516
public final class DecompilerService {
@@ -116,7 +117,7 @@ private synchronized List<File> resources(DecompilerEngine engine) throws IOExce
116117
for (String resource : engine.resources()) {
117118
InputStream input = DecompilerService.class.getResourceAsStream(resource);
118119
if (input == null) throw new FileNotFoundException("Embedded resource is missing: " + resource);
119-
File file = File.createTempFile("jpi-" + engine.name().toLowerCase() + "-", ".jar");
120+
File file = File.createTempFile("jpi-" + engine.name().toLowerCase(Locale.ROOT) + "-", ".jar");
120121
try {
121122
Files.copy(input, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
122123
} finally {

src/main/java/dev/whitedev/jpi/decompile/MethodSourceExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static int descriptorParameterCount(String descriptor) {
4747
}
4848

4949
private static int sourceParameterCount(String source, int start, int end) {
50-
if (source.substring(start, end).trim().isEmpty()) return 0;
50+
if (source.substring(start, end).isBlank()) return 0;
5151
int count = 1;
5252
int round = 0;
5353
int square = 0;
@@ -75,7 +75,7 @@ private static int sourceParameterCount(String source, int start, int end) {
7575

7676
private static String normalizeParameters(String body, String parameters) {
7777
Map<String, String> replacements = new LinkedHashMap<>();
78-
String[] values = parameters.trim().isEmpty() ? new String[0] : parameters.split(",");
78+
String[] values = parameters.isBlank() ? new String[0] : parameters.split(",");
7979
for (int index = 0; index < values.length; index++) {
8080
String value = values[index].trim();
8181
int end = value.length() - 1;

src/main/java/dev/whitedev/jpi/nativeaccess/WindowsNativeAccess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.ArrayList;
2222
import java.util.Comparator;
2323
import java.util.List;
24+
import java.util.Locale;
2425

2526
public final class WindowsNativeAccess {
2627
private static final Kernel32 KERNEL = Kernel32.INSTANCE;
@@ -67,7 +68,7 @@ public List<ProcessInfo> visibleWindows() {
6768
public void injectDll(int pid, File library) throws IOException {
6869
requireWindows();
6970
File dll = library.getCanonicalFile();
70-
if (!dll.isFile() || !dll.getName().toLowerCase().endsWith(".dll")) throw new IOException("Select an existing DLL file");
71+
if (!dll.isFile() || !dll.getName().toLowerCase(Locale.ROOT).endsWith(".dll")) throw new IOException("Select an existing DLL file");
7172
int rights = WinNT.PROCESS_CREATE_THREAD | WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_OPERATION
7273
| WinNT.PROCESS_VM_WRITE | WinNT.PROCESS_VM_READ;
7374
WinNT.HANDLE process = KERNEL.OpenProcess(rights, false, pid);

src/main/java/dev/whitedev/jpi/ui/DllPanel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.swing.border.EmptyBorder;
99
import java.awt.*;
1010
import java.io.File;
11+
import java.util.Locale;
1112

1213
final class DllPanel extends JPanel implements SessionAware {
1314
private final WindowsNativeAccess windows;
@@ -131,7 +132,7 @@ private void inject() {
131132
return;
132133
}
133134
final File library = new File(path.getText());
134-
if (!library.isFile() || !library.getName().toLowerCase().endsWith(".dll")) {
135+
if (!library.isFile() || !library.getName().toLowerCase(Locale.ROOT).endsWith(".dll")) {
135136
Ui.error(this, new IllegalArgumentException("Choose an existing DLL file"));
136137
return;
137138
}

src/main/java/dev/whitedev/jpi/ui/EnvironmentPanel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.awt.*;
1010
import java.awt.datatransfer.StringSelection;
1111
import java.io.File;
12+
import java.util.Locale;
1213

1314
final class EnvironmentPanel extends JPanel implements SessionAware {
1415
private final JTextArea output = Ui.outputArea();
@@ -73,7 +74,7 @@ private void exportSnapshot() {
7374
chooser.setSelectedFile(new File("jpi-snapshot-" + current.target().id() + ".zip"));
7475
if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) return;
7576
File selected = chooser.getSelectedFile();
76-
if (!selected.getName().toLowerCase().endsWith(".zip")) selected = new File(selected.getParentFile(), selected.getName() + ".zip");
77+
if (!selected.getName().toLowerCase(Locale.ROOT).endsWith(".zip")) selected = new File(selected.getParentFile(), selected.getName() + ".zip");
7778
final File destination = selected;
7879
refresh.setEnabled(false);
7980
output.setText("Collecting session snapshot...");

src/main/java/dev/whitedev/jpi/ui/MemoryPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private void scan(final boolean refineExisting) {
160160
return;
161161
}
162162
final String query = value.getText();
163-
if (query.trim().isEmpty()) {
163+
if (query.isBlank()) {
164164
Ui.error(this, new IllegalArgumentException("Enter a value to scan"));
165165
return;
166166
}

0 commit comments

Comments
 (0)