Skip to content

Commit

Permalink
fixed typo, use VT on scheduled executor, use StringBuilders
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Feb 26, 2025
1 parent 0a2b1f4 commit 5ac6da9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class ChannelAdaptor
private final Object disconnectLock = Boolean.TRUE;

private ExecutorService executor;
private ScheduledExecutorService scheduledExcecutor;
private ScheduledExecutorService scheduledExecutor;

private Gauge connectionsGauge;

Expand All @@ -95,11 +95,9 @@ public void initService() throws ConfigurationException {
initSpaceAndQueues();
NameRegistrar.register (getName(), this);
executor = QFactory.executorService(cfg.getBoolean("virtual-threads", false));
scheduledExcecutor = Executors.newSingleThreadScheduledExecutor(r -> {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
});
scheduledExecutor = Executors.newSingleThreadScheduledExecutor(
Thread.ofVirtual().factory()
);
}
public void startService () {
try {
Expand Down Expand Up @@ -409,9 +407,7 @@ public void run () {
}
}
protected void checkConnection () {
while (running() &&
sp.rdp (reconnect) != null)
{
while (running() && sp.rdp (reconnect) != null) {
ISOUtil.sleep(1000);
}
while (running() && !channel.isConnected ()) {
Expand Down Expand Up @@ -442,7 +438,7 @@ protected void disconnect () {
}
private void disconnectLater(long delayInMillis) {
SpaceUtil.wipe(sp, ready);
scheduledExcecutor.schedule(this::disconnect, delayInMillis, TimeUnit.MILLISECONDS);
scheduledExecutor.schedule(this::disconnect, delayInMillis, TimeUnit.MILLISECONDS);
}
public synchronized void setHost (String host) {
setProperty (getProperties ("channel"), "host", host);
Expand Down Expand Up @@ -478,7 +474,7 @@ public void resetCounters () {
lastTxn = 0l;
}
public String getCountersAsString () {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
append (sb, "tx=", tx);
append (sb, ", rx=", rx);
append (sb, ", connects=", connects);
Expand Down Expand Up @@ -515,7 +511,7 @@ public void dump (PrintStream p, String indent) {
protected Space grabSpace (Element e) {
return SpaceFactory.getSpace (e != null ? e.getText() : "");
}
protected void append (StringBuffer sb, String name, int value) {
protected void append (StringBuilder sb, String name, int value) {
sb.append (name);
sb.append (value);
}
Expand Down

0 comments on commit 5ac6da9

Please sign in to comment.