Skip to content

Throw exceptions in executeReadDump() to support shell script error handling ? #283

@R0kshan

Description

@R0kshan

Context

Firstly, thank you for this very handy tool ! We currently use it in our project.

We call it via a shell script like so :

execute_a() {

    output=$(java -Djavax.net.ssl.keyStore=$KEYSTORE_PATH \
                  -Djavax.net.ssl.keyStorePassword=$KEYSTORE_PASSWORD \
                  -Djavax.net.ssl.trustStore=$TRUSTSTORE_PATH \
                  -Djavax.net.ssl.trustStorePassword=$TRUSTSTORE_PASSWORD \
                  -jar $BASEDIR/a-1.6.0-jar-with-dependencies.jar "$@" 2>&1)

    local status=$?

    if [ $status -eq 0 ]; then
        echo "$output" >&1
    else
        echo "Error detected: $output" >&2
        echo "exec_a() : exit $CODE_ERREUR" >&2
        exit $CODE_ERREUR
    fi
}

This execute_a() is called further down our the script like so :

execute_a -U $JMS_USERNAME -P $JMS_PASSWORD -b tcp://$HOSTNAME:61616 -X $PATH_TO_DUMP_FILE -c $NB_MESSAGES $QUEUE -w $WAIT

We recently upgraded from the version 1.4.6 to the latest version 1.6.0 and our scripts no longer sent the right exit code (ex: it sent code 0 when it should have returned an error code 2 in case of an error and the issue was because no exception).

Proposition

To simplify shell script (or another caller) error handling and to ensure that the tool exits with a non-zero exit status when an error occurs (in this case missing path argument for the dump file, or the path is provided but points to a non-existent file) I propose the replace the existant code :

master...R0kshan:a:master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions