Skip to content

Commit

Permalink
Merge pull request #106 from openbase/bugfix/fileRegistryLockingBug
Browse files Browse the repository at this point in the history
Bugfix/file registry locking bug
  • Loading branch information
DivineThreepwood authored Dec 12, 2023
2 parents a637c0d + c29cdf5 commit e4d5c9c
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5Publish
import com.hivemq.client.mqtt.mqtt5.message.subscribe.Mqtt5Subscribe
import com.hivemq.client.mqtt.mqtt5.message.unsubscribe.Mqtt5Unsubscribe
import kotlinx.coroutines.*
import org.openbase.jps.core.JPService
import org.openbase.jul.annotation.RPCMethod
import org.openbase.jul.communication.config.CommunicatorConfig
import org.openbase.jul.communication.iface.RPCServer
Expand Down Expand Up @@ -158,8 +159,12 @@ class RPCServerImpl(
responseBuilder.result = result
} catch (ex: Exception) {
when (ex) {
is InvocationTargetException -> responseBuilder.error =
ex.cause?.stackTraceToString() ?: ex.stackTraceToString()
is InvocationTargetException -> {
if (JPService.verboseMode()) {
ExceptionPrinter.printHistory(ex, logger, LogLevel.WARN)
}
responseBuilder.error = ex.cause?.stackTraceToString() ?: ex.stackTraceToString()
}

else -> {
ExceptionPrinter.printHistory(ex, logger, LogLevel.WARN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,35 @@
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

import org.openbase.jps.core.JPService;
import org.openbase.jps.exception.JPServiceException;
import org.openbase.jps.preset.JPLogLevel;
import org.openbase.jps.preset.JPVerbose;
import org.openbase.jul.exception.*;
import org.openbase.jul.exception.CouldNotPerformException;
import org.openbase.jul.exception.FatalImplementationErrorException;
import org.openbase.jul.exception.MultiException;
import org.openbase.jul.exception.MultiException.SourceExceptionEntry;
import org.openbase.jul.exception.ShutdownInProgressException;
import org.slf4j.Logger;

import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
* @author <a href="mailto:divine@openbase.org">Divine Threepwood</a>
*/
Expand Down Expand Up @@ -273,7 +276,7 @@ private static void exit(final int errorCode) {
System.exit(errorCode);
}

throw new RuntimeException(new ShutdownInProgressException("Shutdown with error code "+ errorCode + " initiated!"));
throw new RuntimeException(new ShutdownInProgressException("Shutdown with error code " + errorCode + " initiated!"));
}

/**
Expand Down Expand Up @@ -323,7 +326,7 @@ public static <T extends Throwable> void printHistory(final T th, final Printer
// throw assertion error in case FatalImplementationErrorException was detected.
printer.print(SEPARATOR);
printer.print(getContext(th), th);
assert ExceptionPrinter.isQuiet() : "Assert because FatalImplementationException was thrown!";
assert ExceptionPrinter.isQuiet() : "Assert because FatalImplementationException was thrown: " + th.getMessage();
} else if (printer.isDebugEnabled()) {
// Print normal stacktrace in debug mode for all errors.
switch (printer.getLogLevel()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
Expand All @@ -24,16 +24,13 @@

import org.openbase.jul.exception.*;
import org.openbase.jul.exception.MultiException.ExceptionStack;
import org.openbase.jul.exception.printer.ExceptionPrinter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;

/**
* @param <S> the type of the data source
Expand Down Expand Up @@ -183,10 +180,10 @@ public void reset() {
* source of the notification is set as this. Because of data encapsulation reasons this method
* is not included within the Observer interface.
* Attention! This method is not thread safe against changes of the observable because the check if the observable has changed is
* done by computing its hash value. Therefore if the observable is a collection and it is changed
* done by computing its hash value. Therefore, if the observable is a collection, and it is changed
* while notifying a concurrent modification exception can occur. To avoid this compute the
* observable hash yourself by setting a hash generator.
* If this method is interrupted a rollback is done by reseting the latestHashValue. Thus the observable
* If this method is interrupted a rollback is done by resetting the latestHashValue. Thus, the observable
* has not changed and false is returned.
*
* @param observable the value which is notified
Expand All @@ -205,10 +202,10 @@ public boolean notifyObservers(final T observable) throws MultiException, CouldN
* Because of data encapsulation reasons this method is not included within the Observer
* interface.
* Attention! This method is not thread safe against changes of the observable because the check if the observable has changed is
* done by computing its hash value. Therefore if the observable is a collection and it is changed
* done by computing its hash value. Therefore, if the observable is a collection, and it is changed
* while notifying a concurrent modification exception can occur. To avoid this compute the
* observable hash yourself by setting a hash generator.
* If this method is interrupted a rollback is done by reseting the latestHashValue. Thus the observable
* If this method is interrupted a rollback is done by resetting the latestHashValue. Thus, the observable
* has not changed and false is returned.
* <p>
* Note: In case the given observable is null this notification will be ignored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
Expand Down Expand Up @@ -134,6 +134,7 @@ public void trigger(final boolean immediately) throws CouldNotPerformException {
*
* @param value the new value which should be published via the next relay.
* @param immediately this flag forces the trigger to relay immediately without respect to the defined max frequency.
*
* @throws CouldNotPerformException is thrown if the trigger could not be handled (e.g. because of a system shutdown).
*/
public synchronized void trigger(final VALUE value, final boolean immediately) throws CouldNotPerformException {
Expand Down
Loading

0 comments on commit e4d5c9c

Please sign in to comment.