git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH] FindBugs: Superclass uses subclass during initialization

From
Sohn, Matthias <matthias.sohn@sap.com>
Date
May 18, 2009, 13:11 UTC
Message-ID
<366BBB1215D0AB4B8A153AF047A287800319BD13@dewdfe18.wdf.sap.corp>
From: Matthias Sohn <matthias.sohn@sap.com>

FindBugs reported the following problem with high priority: /usr/src/egit/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java:58 Initialization of org.spearce.jgit.merge.MergeStrategy accesses class org.spearce.jgit.merge.StrategySimpleTwoWayInCore, which isn't initialized yet.

To fix this problem move instantiation from StrategySimpleTwoWayInCore up to the abstract superclass MergeStrategy.

Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
---
 .../src/org/spearce/jgit/merge/MergeStrategy.java  |    2 +-
 .../jgit/merge/StrategySimpleTwoWayInCore.java     |    2 --
 2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java b/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
index 5439e5c..f5ced72 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
@@ -55,7 +55,7 @@
 	public static final MergeStrategy THEIRS = new StrategyOneSided("theirs", 1);
 
 	/** Simple strategy to merge paths, without simultaneous edits. */
-	public static final ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE = StrategySimpleTwoWayInCore.INSTANCE;
+	public static final ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE = new StrategySimpleTwoWayInCore();
 
 	private static final HashMap<String, MergeStrategy> STRATEGIES = new HashMap<String, MergeStrategy>();
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
index 5d4447c..626fe06 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
@@ -61,8 +61,6 @@
  * file contents.
  */
 public class StrategySimpleTwoWayInCore extends ThreeWayMergeStrategy {
-	static final ThreeWayMergeStrategy INSTANCE = new StrategySimpleTwoWayInCore();
-
 	/** Create a new instance of the strategy. */
 	protected StrategySimpleTwoWayInCore() {
 		//
-- 
1.6.3.1.30.g55524
Message 1 of 1 in “FindBugs: Superclass uses subclass during initialization”
  1. FindBugs: Superclass uses subclass during initializationSohn, Matthias, May 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.