Skip to content

Commit 6fdffee

Browse files
author
Maciej Rosiek
committed
Renamed sprocId to lockId
1 parent 10d0154 commit 6fdffee

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/main/java/de/zalando/sprocwrapper/SProcCall.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,35 @@ public static class AdvisoryLock {
2222

2323
public static class NoLock {
2424
public static final String NAME = "NO_LOCK";
25-
public static final long SPROC_ID = 0L;
26-
public static final AdvisoryLock LOCK = new AdvisoryLock(NAME, SPROC_ID);
25+
public static final long LOCK_ID = 0L;
26+
public static final AdvisoryLock LOCK = new AdvisoryLock(NAME, LOCK_ID);
2727
}
2828

2929
public static class LockOne {
3030
public static final String NAME = "LOCK_ONE";
31-
public static final long SPROC_ID = 1L;
32-
public static final AdvisoryLock LOCK = new AdvisoryLock(NAME, SPROC_ID);
31+
public static final long LOCK_ID = 1L;
32+
public static final AdvisoryLock LOCK = new AdvisoryLock(NAME, LOCK_ID);
3333
}
3434

3535
private final String name;
36-
private final long sprocId;
36+
private final long lockId;
3737

38-
public AdvisoryLock(final String name, final long sprocId) {
38+
public AdvisoryLock(final String name, final long lockId) {
3939
Preconditions.checkNotNull(name, "Name parameter cannot be null.");
40-
Preconditions.checkArgument(sprocId == NoLock.SPROC_ID && Objects.equals(name, NoLock.NAME)
41-
|| sprocId != NoLock.SPROC_ID && !Objects.equals(name, NoLock.NAME),
42-
"SprocId parameter is different than %s (%s) but the name parameter was not changed: [name: %s, sprocId: %s]",
43-
NoLock.SPROC_ID, NoLock.NAME, name, sprocId);
40+
Preconditions.checkArgument(lockId == NoLock.LOCK_ID && Objects.equals(name, NoLock.NAME)
41+
|| lockId != NoLock.LOCK_ID && !Objects.equals(name, NoLock.NAME),
42+
"LockId parameter is different than %s (%s) but the name parameter was not changed: [name: %s, lockId: %s]",
43+
NoLock.LOCK_ID, NoLock.NAME, name, lockId);
4444
this.name = name;
45-
this.sprocId = sprocId;
45+
this.lockId = lockId;
4646
}
4747

4848
public String getName() {
4949
return name;
5050
}
5151

52-
public long getSprocId() {
53-
return sprocId;
52+
public long getLockId() {
53+
return lockId;
5454
}
5555

5656
@Override
@@ -65,7 +65,7 @@ public boolean equals(final Object o) {
6565

6666
final AdvisoryLock that = (AdvisoryLock) o;
6767

68-
if (sprocId != that.sprocId) {
68+
if (lockId != that.lockId) {
6969
return false;
7070
}
7171

@@ -79,13 +79,13 @@ public boolean equals(final Object o) {
7979
@Override
8080
public int hashCode() {
8181
int result = name.hashCode();
82-
result = 31 * result + (int) (sprocId ^ (sprocId >>> 32));
82+
result = 31 * result + (int) (lockId ^ (lockId >>> 32));
8383
return result;
8484
}
8585

8686
@Override
8787
public String toString() {
88-
return "AdvisoryLock{" + "name='" + name + '\'' + ", sprocId=" + sprocId + '}';
88+
return "AdvisoryLock{" + "name='" + name + '\'' + ", lockId=" + lockId + '}';
8989
}
9090
}
9191

@@ -149,7 +149,7 @@ public static enum WriteTransaction {
149149

150150
long timeoutInMilliSeconds() default 0;
151151

152-
long adivsoryLockSprocId() default AdvisoryLock.NoLock.SPROC_ID;
152+
long adivsoryLockId() default AdvisoryLock.NoLock.LOCK_ID;
153153

154154
String adivsoryLockName() default AdvisoryLock.NoLock.NAME;
155155

src/main/java/de/zalando/sprocwrapper/proxy/SProcProxyBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static <T> T build(final DataSourceProvider d, final Class<T> c) {
137137
storedProcedure = new StoredProcedure(name, method.getGenericReturnType(), sprocStrategy,
138138
scA.runOnAllShards(), scA.searchShards(), scA.parallel(), resultMapper,
139139
scA.timeoutInMilliSeconds(),
140-
new SProcCall.AdvisoryLock(scA.adivsoryLockName(), scA.adivsoryLockSprocId()), useValidation,
140+
new SProcCall.AdvisoryLock(scA.adivsoryLockName(), scA.adivsoryLockId()), useValidation,
141141
scA.readOnly(), writeTransaction);
142142
if (!"".equals(scA.sql())) {
143143
storedProcedure.setQuery(scA.sql());

src/main/java/de/zalando/sprocwrapper/proxy/executors/ExecutorWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private boolean lockAdvisoryLock(final Connection conn) throws SQLException {
6565
}
6666

6767
final Statement st = conn.createStatement();
68-
final ResultSet rs = st.executeQuery("SELECT pg_advisory_lock(" + lock.getSprocId() + ") AS \"" + lock
68+
final ResultSet rs = st.executeQuery("SELECT pg_advisory_lock(" + lock.getLockId() + ") AS \"" + lock
6969
.getName() + "\";");
7070

7171
boolean b = false;
@@ -84,7 +84,7 @@ private boolean unlockAdvisoryLock(final Connection conn) throws SQLException {
8484
}
8585

8686
final Statement st = conn.createStatement();
87-
final ResultSet rs = st.executeQuery("SELECT pg_advisory_unlock(" + lock.getSprocId() + ")");
87+
final ResultSet rs = st.executeQuery("SELECT pg_advisory_unlock(" + lock.getLockId() + ")");
8888
boolean b = false;
8989
if (rs.next()) {
9090
b = rs.getBoolean(1);

src/test/java/de/zalando/sprocwrapper/AdvisoryLockTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class AdvisoryLockTest {
77

88
@Test(expected = IllegalArgumentException.class)
99
public void shouldNotCreateAdvisoryLockWithWrongName() {
10-
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.SPROC_ID + 1);
10+
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.LOCK_ID + 1);
1111
}
1212

1313
@Test
@@ -18,9 +18,9 @@ public void shouldCreateAdvisoryLockWithCorrectName() {
1818
@Test
1919
public void shouldCompareLocksCorrectly() {
2020
Assert.assertEquals(SProcCall.AdvisoryLock.NoLock.LOCK,
21-
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.SPROC_ID));
21+
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.LOCK_ID));
2222
Assert.assertNotEquals(SProcCall.AdvisoryLock.LockOne.LOCK,
23-
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.SPROC_ID));
23+
new SProcCall.AdvisoryLock(SProcCall.AdvisoryLock.NoLock.NAME, SProcCall.AdvisoryLock.NoLock.LOCK_ID));
2424
}
2525

2626
}

0 commit comments

Comments
 (0)