Java patch workflow
Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-sonnet-4-6/fix-security-bug/java-patch-workflow
Workflow for creating and applying patches to Java projects - diff format, patch application, and Maven rebuilds for security fixes.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill java-patch-workflowAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
2.4 KB, 570 tokens by cl100k_base, as published. Nobody here has run it
Java Patch Workflow
Creating Unified Diff Patches
# Create a patch from changes to a specific file
diff -u original_file.java modified_file.java > my_fix.patch
# Create patch with context lines
diff -u -p original.java modified.java > fix.patch
# Apply a patch
patch -p1 < fix.patch # Strip 1 prefix component
patch -p0 < fix.patch # Don't strip (exact path match)
patch --dry-run -p1 < fix.patch # Test without applying
Git-Based Patching
# Create patch from staged changes
git diff HEAD > my_fix.patch
# Create patch from specific commit
git format-patch HEAD~1
# Apply git format-patch
git am patch_file.patch
# Apply unified diff
git apply patch_file.patch
git apply --check patch_file.patch # Dry run
Apache Druid Build
Full Build (skip web-console for OOM prevention)
cd /root/druid
mvn clean package -DskipTests \
-Dcheckstyle.skip=true -Dpmd.skip=true \
-Dforbiddenapis.skip=true -Dspotbugs.skip=true \
-Danimal.sniffer.skip=true -Denforcer.skip=true \
-Djacoco.skip=true -Ddependency-check.skip=true \
-pl '!web-console' -pl indexing-service -am
Module-Specific Build
# Build only the indexing-service and dependencies
mvn package -DskipTests -pl indexing-service -am
# Build specific module with quality checks skipped
mvn package -DskipTests -Dcheckstyle.skip=true -pl processing
Patch File Organization
/root/patches/
├── 01-fix-javascript-injection.patch # Primary root cause fix
├── 02-fix-sampler-validation.patch # Defense in depth
└── README.md # Fix description
Common Issues
Patch Offset Errors
If patch reports "offset" or "fuzz", the patch may be for a different file version.
Use patch --fuzz=3 to allow more context flexibility.
Build Failures After Patch
- Check for compilation errors:
mvn compilefirst - Verify imports are added for new classes used
- Check Guice injection: ensure
@Injectannotation is present for DI
Finding the Right JAR After Build
find /root/druid -name "druid-indexing-service-*.jar" -not -path "*/test*"
# Typically at: druid/indexing-service/target/druid-indexing-service-*.jar
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.