This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new a5e241a42f SonarQube bug fixes
a5e241a42f is described below
commit a5e241a42f2482f7a5a1f046502ee65ea33bd9e5
Author: James Bognar <[email protected]>
AuthorDate: Mon Feb 9 11:45:53 2026 -0500
SonarQube bug fixes
---
AI.md | 2 +-
.../java/org/apache/juneau/junit/bct/Swappers.java | 3 +
.../org/apache/juneau/config/store/FileStore.java | 2 +
.../microservice/resources/ShutdownResource.java | 2 +-
.../microservice/jetty/JettyMicroservice.java | 2 +-
.../rest/client/BasicHttpRequestRetryHandler.java | 2 +-
scripts/push.py | 80 ++++++++++++++++++++++
7 files changed, 89 insertions(+), 4 deletions(-)
diff --git a/AI.md b/AI.md
index 1cc30f8dc5..b315ae3d1b 100644
--- a/AI.md
+++ b/AI.md
@@ -25,7 +25,7 @@ This document outlines the rules, guidelines, and best
practices that AI assista
- **"revert unstaged"** - Runs `scripts/revert-unstaged.py`
- **"start jetty"** - Runs `scripts/start-examples-rest-jetty.py`
- **"start springboot"** - Runs `scripts/start-examples-springboot.py`
-- **"push [commit message]"** - Runs `scripts/build-and-push.py` with the
commit message. Example: "push Added Algolia search"
+- **"push"** or **"push changes"** - When the user asks to push changes, use
`./scripts/push.py "Commit message"` to push changes. **Always prompt the user
for the commit message** and provide 2-3 suggested commit message options based
on the changes made. Example: `./scripts/push.py "Replace
Stream.collect(Collectors.toList()) with Stream.toList()"`
- **"test"** - Runs `scripts/build-and-test.py`
### Documentation Commands
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Swappers.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Swappers.java
index 2278397b88..a593837d0b 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Swappers.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Swappers.java
@@ -123,6 +123,9 @@ public class Swappers {
if (future.isDone() && ! future.isCancelled()) {
try {
return future.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return "<interrupted>";
} catch (Exception e) {
return "<error: " + e.getMessage() +
">";
}
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java
index 124ef8de00..ca3983620b 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java
@@ -380,6 +380,8 @@ public class FileStore extends ConfigStore {
if (! key.reset())
break;
}
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
} catch (Exception e) {
throw toRex(e);
}
diff --git
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/ShutdownResource.java
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/ShutdownResource.java
index 57ffc2f96d..e0406b35c4 100755
---
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/ShutdownResource.java
+++
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/ShutdownResource.java
@@ -45,7 +45,7 @@ public class ShutdownResource extends BasicRestServlet {
Thread.sleep(1000);
System.exit(0);
} catch (InterruptedException e) {
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
}).start();
return "OK";
diff --git
a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
index 877cdcb17c..9fc527365d 100644
---
a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
+++
b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
@@ -768,7 +768,7 @@ public class JettyMicroservice extends Microservice {
try {
t.join();
} catch (InterruptedException e) {
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
super.stop();
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/BasicHttpRequestRetryHandler.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/BasicHttpRequestRetryHandler.java
index acc0b3add4..81d5851dab 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/BasicHttpRequestRetryHandler.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/BasicHttpRequestRetryHandler.java
@@ -58,7 +58,7 @@ class BasicHttpRequestRetryHandler extends
StandardHttpRequestRetryHandler {
try {
Thread.sleep(retryInterval);
} catch (InterruptedException e) {
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
}
return super.retryRequest(exception, executionCount, context);
diff --git a/scripts/push.py b/scripts/push.py
index 8d2acc673b..3bc0562235 100755
--- a/scripts/push.py
+++ b/scripts/push.py
@@ -229,6 +229,73 @@ def check_git_status(repo_dir):
return True
+def check_upstream_changes(repo_dir):
+ """
+ Check if local branch is behind upstream/remote branch.
+
+ Returns:
+ tuple: (is_behind, error_message)
+ - is_behind: True if local is behind remote, False otherwise
+ - error_message: Error message if check failed, None otherwise
+ """
+ try:
+ # Get current branch name
+ result = subprocess.run(
+ ["git", "rev-parse", "--abbrev-ref", "HEAD"],
+ cwd=repo_dir,
+ capture_output=True,
+ text=True,
+ check=True
+ )
+ current_branch = result.stdout.strip()
+
+ # Fetch latest from remote
+ subprocess.run(
+ ["git", "fetch"],
+ cwd=repo_dir,
+ capture_output=True,
+ text=True,
+ check=True
+ )
+
+ # Check if there's a remote tracking branch
+ result = subprocess.run(
+ ["git", "rev-parse", "--abbrev-ref",
f"{current_branch}@{{upstream}}"],
+ cwd=repo_dir,
+ capture_output=True,
+ text=True,
+ check=False
+ )
+
+ if result.returncode != 0:
+ # No upstream branch configured, skip check
+ return (False, None)
+
+ upstream_branch = result.stdout.strip()
+
+ # Get commit counts
+ result = subprocess.run(
+ ["git", "rev-list", "--left-right", "--count",
f"{current_branch}...{upstream_branch}"],
+ cwd=repo_dir,
+ capture_output=True,
+ text=True,
+ check=True
+ )
+
+ # Output format: "X\tY" where X is commits ahead, Y is commits behind
+ counts = result.stdout.strip().split('\t')
+ if len(counts) != 2:
+ return (False, "Could not parse upstream comparison")
+
+ commits_behind = int(counts[1])
+ return (commits_behind > 0, None)
+
+ except subprocess.CalledProcessError as e:
+ return (False, f"Git command failed: {e}")
+ except Exception as e:
+ return (False, f"Error checking upstream changes: {e}")
+
+
# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
def play_sound(success=True):
"""
@@ -418,6 +485,19 @@ Examples:
return 1
step_num += 1
+ # Check if local branch is behind upstream
+ print(f"\n🔍 Checking for upstream changes...")
+ is_behind, error_msg = check_upstream_changes(juneau_root)
+ if error_msg:
+ print(f"\n⚠ Warning: Could not check upstream changes: {error_msg}")
+ print("Continuing anyway...")
+ elif is_behind:
+ print("\n❌ ERROR: Local branch is behind upstream/remote branch.")
+ print("Please pull/merge upstream changes before pushing.")
+ print("Run: git pull")
+ play_sound(success=False)
+ return 1
+
# Check if there are changes to commit
if not check_git_status(juneau_root):
print("\n⚠ Warning: No changes detected. Skipping commit and push.")