Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,8 @@ else
fi

if [ $runSpotBugs == "yes" ]; then
# mvn com.github.spotbugs:spotbugs-maven-plugin:spotbugs # spotbugs goal produces a report target/spotbugsXml.xml for each module
$mvn com.github.spotbugs:spotbugs-maven-plugin:check # check goal produces a report and produces build failed if bugs
# the spotbugsXml.xml file is easiest read in a web browser
# see http://spotbugs.readthedocs.io/en/latest/maven.html and https://spotbugs.github.io/spotbugs-maven-plugin/index.html for more info
if [ $? != 0 ] ; then echo "spotbugs failure" ; exit 1 ; fi
libexec/spotbugs.sh ${mvnArgs[@]:-} || (echo "ERROR: spotbugs failure" >&2 && exit 1)
echo "spotbugs spotted no bugs!"
fi

# installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class DCdatabase {
private DCdatabase() {
}

public static DCdatabase getInstance() {
public static synchronized DCdatabase getInstance() {
if (instance == null) {
instance = new DCdatabase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Benchmark {
private Timer updateTimer = null;


public Benchmark(){
private Benchmark(){

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,28 @@ public static List<String> getFileList(String env, String rpath){
}
return ClasUtilsFile.getFileList(directory);
}
/**
* returns a file list that contains files with given extension
* @param env
* @param rpath
* @param ext
* @return
*/
public static List<String> getFileList(String env, String rpath, String ext){
String directory = ClasUtilsFile.getResourceDir(env, rpath);
if(directory!=null) return new ArrayList<>();

List<String> files = ClasUtilsFile.getFileList(directory);
List<String> selected = new ArrayList<>();
for(String item : files){
if(item.endsWith(ext)==true) selected.add(item);
}
return selected;
}


// FIXME: unused, and spotbugs detects rank-7 bug `NP_NULL_PARAM_DEREF_NONVIRTUAL`;
// should we just remove this function?
// /**
// * returns a file list that contains files with given extension
// * @param env
// * @param rpath
// * @param ext
// * @return
// */
// public static List<String> getFileList(String env, String rpath, String ext){
// String directory = ClasUtilsFile.getResourceDir(env, rpath);
// if(directory!=null) return new ArrayList<>();
//
// List<String> files = ClasUtilsFile.getFileList(directory);
// List<String> selected = new ArrayList<>();
// for(String item : files){
// if(item.endsWith(ext)==true) selected.add(item);
// }
// return selected;
// }

public static void writeFile(String filename, List<String> lines){
System.out.println("writing file ---> " + filename);
BufferedWriter writer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.ZoneId;
import java.time.Instant;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -40,14 +41,9 @@ public class MagneticFields {
/**
* A formatter to get the time in down to seconds (no day info).
*/
private static SimpleDateFormat formatterlong;

static {
TimeZone tz = TimeZone.getDefault();

formatterlong = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
formatterlong.setTimeZone(tz);
}
private static final DateTimeFormatter formatterlong = DateTimeFormatter
.ofPattern("yyyy/MM/dd HH:mm:ss")
.withZone(ZoneId.systemDefault());

// version of mag field package
private static String VERSION = "1.20";
Expand Down Expand Up @@ -127,7 +123,7 @@ public String getVersion() {
*
* @return the MagneticFields singleton
*/
public static MagneticFields getInstance() {
public static synchronized MagneticFields getInstance() {
if (instance == null) {
instance = new MagneticFields();
}
Expand Down Expand Up @@ -1660,7 +1656,7 @@ public String fileBaseNames() {
* @return a string representation of the current time, down to seconds.
*/
public static String dateStringLong(long longtime) {
return formatterlong.format(longtime);
return formatterlong.format(Instant.ofEpochMilli(longtime));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void done() {
zIndex++;
}

if ((gdata[PHI].max > 31) && (gdata[PHI].max > 31)) {
if (gdata[PHI].max > 31) {
System.err.println("Correcting PhiMax to 360 from " + gdata[PHI].max);
}

Expand Down Expand Up @@ -850,4 +850,4 @@ public static void memoryToGEMCTorusConverter() {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ColorScaleModel {
* @param minVal the minimum value;
* @param maxVal the maximum value the array of colors.
*/
public ColorScaleModel(double minVal, double maxVal, Color[] colors) {
private ColorScaleModel(double minVal, double maxVal, Color[] colors) {
_colors = colors;
_minVal = minVal;
_maxVal = maxVal;
Expand All @@ -52,7 +52,7 @@ public ColorScaleModel(double minVal, double maxVal, Color[] colors) {
*
* @return a standard blue to red color scale
*/
public static ColorScaleModel blueToRed() {
public static synchronized ColorScaleModel blueToRed() {
if (_blueToRed == null) {
Color colors[] = {
// new Color(0, 0, 139),
Expand Down Expand Up @@ -245,4 +245,4 @@ private Color getInterpretedColor(Color c1, Color c2, double fract) {
return new Color(r3, g3, b3, a3);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Font getCommonFont(int size) {
*
* @return the singleton object.
*/
public static Environment getInstance() {
public static synchronized Environment getInstance() {
if (instance == null) {
instance = new Environment();
}
Expand Down Expand Up @@ -287,4 +287,4 @@ public static void memoryReport(String message) {
public static void main(String arg[]) {
System.out.println(Environment.getInstance());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private ImageManager() {
*
* @return the image manager singleton.
*/
public static ImageManager getInstance() {
public static synchronized ImageManager getInstance() {
if (imageManager == null) {
try {
imageManager = new ImageManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public PlotCanvas(DataSet dataSet, String plotTitle, String xLabel, String yLabe
}
catch (DataSetException e) {
e.printStackTrace();
System.exit(1);
}
}

Expand Down
5 changes: 5 additions & 0 deletions libexec/spotbugs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# run spotbugs; additional arguments are passed to `mvn` (such as `-T`)
set -euo pipefail
mvn spotbugs:check "$@"
# mvn spotbugs:gui --no-transfer-progress # must be single-threaded
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
<version>4.9.6</version>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,26 +318,30 @@ private void delA_delt(double tx, double ty, double Bx, double By, double Bz, do


private double beta = 1.0;
public void setMass(int hypo, double mass) {

switch (hypo) {
case 0:
mass = 0.000510998;
break;
case 1:
mass = 0.13957018;
break;
case 2:
mass = 0.493677;
break;
case 3:
mass = 0.105658369;
break;
case 4:
mass = 0.938272029;
break;
}
}

// FIXME: `mass` parameter is dead upon entry but overwritten
// (spotbugs bug `IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN`)
// Can we just remove this?
// public void setMass(int hypo, double mass) {
//
// switch (hypo) {
// case 0:
// mass = 0.000510998;
// break;
// case 1:
// mass = 0.13957018;
// break;
// case 2:
// mass = 0.493677;
// break;
// case 3:
// mass = 0.105658369;
// break;
// case 4:
// mass = 0.938272029;
// break;
// }
// }


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,26 +293,30 @@ private void delA_delt(double tx, double ty, double Bx, double By, double Bz, do


private double beta = 1.0;
public void setMass(int hypo, double mass) {

switch (hypo) {
case 0:
mass = 0.000510998;
break;
case 1:
mass = 0.13957018;
break;
case 2:
mass = 0.493677;
break;
case 3:
mass = 0.105658369;
break;
case 4:
mass = 0.938272029;
break;
}
}

// FIXME: `mass` parameter is dead upon entry but overwritten
// (spotbugs bug `IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN`)
// Can we just remove this?
// public void setMass(int hypo, double mass) {
//
// switch (hypo) {
// case 0:
// mass = 0.000510998;
// break;
// case 1:
// mass = 0.13957018;
// break;
// case 2:
// mass = 0.493677;
// break;
// case 3:
// mass = 0.105658369;
// break;
// case 4:
// mass = 0.938272029;
// break;
// }
// }


/**
Expand Down
4 changes: 4 additions & 0 deletions reconstruction/ltcc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<artifactId>javafx-base</artifactId>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.jlab</groupId>
<artifactId>groot</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.LinkedList;
import java.util.List;
import jakarta.annotation.Nullable;
import org.jlab.detector.banks.RawDataBank;
import org.jlab.geom.prim.Vector3D;

Expand Down Expand Up @@ -85,9 +86,9 @@ public static List <LTCCHit> loadHits(DataEvent event) {

LTCCHit(RawDataBank bank,
int index,
IndexedTable spe,
IndexedTable timing_offset,
IndexedTable status_table) {
@Nullable IndexedTable spe,
@Nullable IndexedTable timing_offset,
@Nullable IndexedTable status_table) {
this.sector = bank.getByte("sector", index);
this.segment = bank.getShort("component", index);
this.side = bank.trueOrder(index) + 1;
Expand Down
Loading
Loading