If you are new to submitting patches to open source or new to submitting patches to Apache, I'd suggest you start by reading the On Contributing Patches page from Apache Commons Project. Its a nice overview that applies equally to the Apache HBase Project.
See the aforementioned Apache Commons link for how to make patches against a checked out subversion repository. Patch files can also be easily generated from Eclipse, for example by selecting "Team -> Create Patch". Patches can also be created by git diff and svn diff.
Please submit one patch-file per Jira. For example, if multiple files are changed make sure the selected resource when generating the patch is a directory. Patch files can reflect changes in multiple files.
Make sure you review Section 15.2.1.1, “Code Formatting” for code style.
The patch file should have the Apache HBase Jira ticket in the name. For example, if a patch was submitted for Foo.java
, then
a patch file called Foo_HBASE_XXXX.patch
would be acceptable where XXXX is the Apache HBase Jira number.
If you generating from a branch, then including the target branch in the filename is advised, e.g., HBASE-XXXX-0.90.patch
.
Yes, please. Please try to include unit tests with every code patch (and especially new classes and large changes). Make sure unit tests pass locally before submitting the patch.
Also, see Section 15.10.2.1, “Mockito”.
If you are creating a new unit test class, notice how other unit test classes have classification/sizing annotations at the top and a static method on the end. Be sure to include these in any new unit test files you generate. See Section 15.7, “Tests” for more on how the annotations work.
The patch should be attached to the associated Jira ticket "More Actions -> Attach Files". Make sure you click the ASF license inclusion, otherwise the patch can't be considered for inclusion.
Once attached to the ticket, click "Submit Patch" and the status of the ticket will change. Committers will review submitted patches for inclusion into the codebase. Please understand that not every patch may get committed, and that feedback will likely be provided on the patch. Fear not, though, because the Apache HBase community is helpful!
The following items are representative of common patch feedback. Your patch process will go faster if these are taken into account before submission.
See the Java coding standards for more information on coding conventions in Java.
Rather than do this...
if ( foo.equals( bar ) ) { // don't do this
... do this instead...
if (foo.equals(bar)) {
Also, rather than do this...
foo = barArray[ i ]; // don't do this
... do this instead...
foo = barArray[i];
Auto-generated code in Eclipse often looks like this...
public void readFields(DataInput arg0) throws IOException { // don't do this foo = arg0.readUTF(); // don't do this
... do this instead ...
public void readFields(DataInput di) throws IOException { foo = di.readUTF();
See the difference? 'arg0' is what Eclipse uses for arguments by default.
Keep lines less than 100 characters.
Bar bar = foo.veryLongMethodWithManyArguments(argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9); // don't do this
... do something like this instead ...
Bar bar = foo.veryLongMethodWithManyArguments( argument1, argument2, argument3,argument4, argument5, argument6, argument7, argument8, argument9);
This happens more than people would imagine.
Bar bar = foo.getBar(); <--- imagine there's an extra space(s) after the semicolon instead of a line break.
Make sure there's a line-break after the end of your code, and also avoid lines that have nothing but whitespace.
In 0.96, HBase moved to protobufs. The below section on Writables applies to 0.94.x and previous, not to 0.96 and beyond.
Every class returned by RegionServers must implement Writable
. If you
are creating a new class that needs to implement this interface, don't forget the default constructor.
This is also a very common feedback item. Don't forget Javadoc!
Javadoc warnings are checked during precommit. If the precommit tool gives you a '-1', please fix the javadoc issue. Your patch won't be committed if it adds such warnings.
Findbugs is used to detect common bugs pattern. As Javadoc, it is checked during the precommit build up on Apache's Jenkins, and as with Javadoc, please fix them. You can run findbugs locally with 'mvn findbugs:findbugs': it will generate the findbugs files locally. Sometimes, you may have to write code smarter than Findbugs. You can annotate your code to tell Findbugs you know what you're doing, by annotating your class with:
@edu.umd.cs.findbugs.annotations.SuppressWarnings( value="HE_EQUALS_USE_HASHCODE", justification="I know what I'm doing")
Note that we're using the apache licensed version of the annotations.
Don't just leave the @param arguments the way your IDE generated them. Don't do this...
/** * * @param bar <---- don't do this!!!! * @return <---- or this!!!! */ public Foo getFoo(Bar bar);
... either add something descriptive to the @param and @return lines, or just remove them. But the preference is to add something descriptive and useful.
If you submit a patch for one thing, don't do auto-reformatting or unrelated reformatting of code on a completely different area of code.
Likewise, don't add unrelated cleanup or refactorings outside the scope of your Jira.
Larger patches should go through ReviewBoard.
For more information on how to use ReviewBoard, see the ReviewBoard documentation.
Committers do this. See How To Commit in the Apache HBase wiki.
Commiters will also resolve the Jira, typically after the patch passes a build.
If a committer commits a patch it is their responsibility to make sure it passes the test suite. It is helpful if contributors keep an eye out that their patch does not break the hbase build and/or tests but ultimately, a contributor cannot be expected to be up on the particular vagaries and interconnections that occur in a project like hbase. A committer should.