Skip to content

Commit 98bd330

Browse files
authored
Merge pull request OpenHFT#26 from DevFactory/release/Utility-classes-should-not-have-public-constructors-fix-1
squid:S1118 - Utility classes should not have public constructors
2 parents 58f0e9c + b90a293 commit 98bd330

6 files changed

Lines changed: 27 additions & 5 deletions

File tree

affinity/src/main/java/net/openhft/affinity/impl/Utilities.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
/**
88
* Created by andre on 20/06/15.
99
*/
10-
public class Utilities {
10+
public final class Utilities {
11+
private Utilities() {
12+
throw new InstantiationError( "Must not instantiate this class" );
13+
}
1114
/**
1215
* Creates a hexademical representation of the bit set
1316
*

affinity/src/main/java/net/openhft/ticker/Ticker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public final class Ticker {
3535
}
3636
}
3737

38+
private Ticker() {
39+
throw new InstantiationError( "Must not instantiate this class" );
40+
}
41+
3842
/**
3943
* @return The current value of the system timer, in nanoseconds.
4044
*/

affinity/src/test/java/net/openhft/affinity/AffinityLockBindMain.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
/**
2222
* @author peter.lawrey
2323
*/
24-
public class AffinityLockBindMain {
24+
public final class AffinityLockBindMain {
25+
private AffinityLockBindMain() {
26+
throw new InstantiationError( "Must not instantiate this class" );
27+
}
28+
2529
public static void main(String... args) throws InterruptedException {
2630
AffinityLock al = AffinityLock.acquireLock();
2731
try {

affinity/src/test/java/net/openhft/affinity/AffinityLockMain.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
/**
2020
* @author peter.lawrey
2121
*/
22-
public class AffinityLockMain {
22+
public final class AffinityLockMain {
23+
private AffinityLockMain() {
24+
throw new InstantiationError( "Must not instantiate this class" );
25+
}
26+
2327
public static void main(String... args) throws InterruptedException {
2428
AffinityLock al = AffinityLock.acquireLock();
2529
try {

affinity/src/test/java/net/openhft/affinity/AffinitySupportMain.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
/**
2020
* @author peter.lawrey
2121
*/
22-
public class AffinitySupportMain {
22+
public final class AffinitySupportMain {
23+
private AffinitySupportMain() {
24+
throw new InstantiationError( "Must not instantiate this class" );
25+
}
26+
2327
public static void main(String... args) {
2428
AffinityLock al = AffinityLock.acquireLock();
2529
try {

affinity/src/test/java/net/openhft/affinity/AffinityThreadFactoryMain.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
/**
2727
* @author peter.lawrey
2828
*/
29-
public class AffinityThreadFactoryMain {
29+
public final class AffinityThreadFactoryMain {
3030
private static final ExecutorService ES = Executors.newFixedThreadPool(4,
3131
new AffinityThreadFactory("bg", SAME_CORE, DIFFERENT_SOCKET, ANY));
3232

33+
private AffinityThreadFactoryMain(){
34+
throw new InstantiationError( "Must not instantiate this class" );
35+
}
3336
public static void main(String... args) throws InterruptedException {
3437
for (int i = 0; i < 12; i++)
3538
ES.submit(new Callable<Void>() {

0 commit comments

Comments
 (0)