Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.Cleaner;
import java.nio.channels.Channels;
import java.nio.channels.ClosedByInterruptException;
import java.text.SimpleDateFormat;
Expand All @@ -43,7 +44,7 @@ public class ConsoleService extends JavaService {
private String timestampFormat = TIMESTAMP_DEFAULT_FORMAT;

private class ConsoleInputThread extends Thread {
private boolean keepRun = true;
private volatile boolean keepRun = true;

public void kill() {
keepRun = false;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void run() {
}

private ConsoleInputThread consoleInputThread;
private final Cleaner cleaner = Cleaner.create();

@RequestResponse
public void registerForInput( Value request ) {
Expand All @@ -91,19 +93,10 @@ public void registerForInput( Value request ) {
}
}
consoleInputThread = new ConsoleInputThread();
cleaner.register( consoleInputThread, consoleInputThread::kill );
consoleInputThread.start();
}

@Override
protected void finalize()
throws Throwable {
try {
consoleInputThread.kill();
} finally {
super.finalize();
}
}

@RequestResponse
public void print( String s ) {
if( enableTimestamp ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package joliex.util;


import java.lang.ref.Cleaner;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -70,6 +71,8 @@ public Interpreter interpreter() {
}

private TimeThread thread = null;
private final Cleaner cleaner = Cleaner.create();

private final DateFormat dateFormat, dateTimeFormat;
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
private final Map< Long, ScheduledFuture< ? > > scheduledFutureHashMap = new ConcurrentHashMap<>();
Expand All @@ -80,24 +83,13 @@ public TimeService() {
dateTimeFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.MEDIUM );
}

@Override
protected void finalize()
throws Throwable {
try {
if( thread != null ) {
thread.interrupt();
}
} finally {
super.finalize();
}
}

private void launchTimeThread( long waitTime, String callbackOperation, Value callbackValue ) {
waitTime = (waitTime > 0) ? waitTime : 0L;
if( thread != null ) {
thread.interrupt();
}
thread = new TimeThread( this, waitTime, callbackOperation, callbackValue );
cleaner.register( thread, thread::interrupt );
thread.start();
}

Expand Down
12 changes: 5 additions & 7 deletions jolie/src/main/java/jolie/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public CorrelationSet correlationInitializer() {
private final String logPrefix;
private final Tracer tracer;

private boolean check = false;
private volatile boolean check = false;
private static final long PERSISTENT_CONNECTION_TIMEOUT = 2 * 1000; // 2 seconds
private static final long AWAIT_TERMINATION_TIMEOUT = 5 * 1000; // 5 seconds

Expand Down Expand Up @@ -561,12 +561,10 @@ public void exit() {
* @param terminationTimeout the timeout for the wait of the termination of running processes
*/
public void exit( long terminationTimeout ) {
synchronized( this ) {
if( exiting ) {
return;
} else {
exiting = true;
}
if( exiting ) {
return;
} else {
exiting = true;
}
exitingLock.lock();
try {
Expand Down
4 changes: 3 additions & 1 deletion jolie/src/main/java/jolie/net/SocketCommChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ protected void sendImpl( CommMessage message )
throws IOException {
try {
protocol().send( ostream, message, istream );
ostream.flush();
if( socketChannel.isOpen() ) {
ostream.flush();
}
} catch( IllegalBlockingModeException e ) {
throw new IOException( e );
}
Expand Down
9 changes: 6 additions & 3 deletions libjolie/src/main/java/jolie/lang/parse/module/JapSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ public JapSource( URI uri ) throws FileNotFoundException {
if( manifest != null ) {
// See if a main program is defined through a Manifest attribute
Attributes attrs = manifest.getMainAttributes();
this.filePath = attrs.getValue( Constants.Manifest.MAIN_PROGRAM );
this.moduleEntry = japFile.getEntry( this.filePath );
if( attrs.containsKey( Constants.Manifest.MAIN_PROGRAM ) ) {
this.filePath = attrs.getValue( Constants.Manifest.MAIN_PROGRAM );
} else {
this.filePath = Paths.get( this.japFile.getName() ).toUri().toString() + ".ol";
}
} else {
// guess by name
this.filePath = Paths.get( this.japFile.getName() ).toUri().toString() + ".ol";
this.moduleEntry = this.japFile.getEntry( this.filePath );
}
this.moduleEntry = this.japFile.getEntry( this.filePath );
}
if( this.moduleEntry == null ) {
throw new FileNotFoundException( uri.toString() );
Expand Down
3 changes: 0 additions & 3 deletions test/services/jester.ol
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ define doTest {

getJesterConfig@JesterConfigurator( jester )( config );


println@Console( s )()

loadEmbeddedService@Runtime( { .filepath = "-C DEBUG=false" +
" -C API_ROUTER_HTTP=\"socket://" + router_host +
"\" -C API_ROUTER_HTTPS=\"local" +
Expand Down
Loading