<NME> GenieAgentApplication.java
<BEF> /*
 *
 *  Copyright 2018 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
package com.netflix.genie;

import com.netflix.genie.agent.cli.UserConsole;
import com.netflix.genie.agent.cli.Util;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.context.annotation.Configuration;

/**
 * Genie Agent application.
 *
 * @author mprimi
 * @author tgianos
 * @since 4.0.0
 */
@Configuration
@EnableAutoConfiguration(
    exclude = {
        /*
         * Picked up by default but not believed to be needed currently
         */
        GsonAutoConfiguration.class,
        JacksonAutoConfiguration.class,
        PersistenceExceptionTranslationAutoConfiguration.class,
        TransactionAutoConfiguration.class,
    }
)
public class GenieAgentApplication {
    /**
     * Main method, actual execution is delegated to GenieAgentRunner.
     *
     * @param args command-line arguments
     */
    public static void main(final String[] args) {
        UserConsole.getLogger().info("Starting Genie Agent");
        System.exit(new GenieAgentApplication().run(args));
    }

    private int run(final String[] args) {
        final SpringApplication app = new SpringApplication(GenieAgentApplication.class);
        // Disable parsing of command-line arguments into properties.
        app.setAddCommandLineProperties(false);

        //TODO: workaround for https://jira.spring.io/browse/SPR-17416
        // Spring chokes on argument '--' (a.k.a. bare double dash) conventionally used to separate options from
        // operands. Perform a token replacement to avoid triggering an error in Spring argument parsing.
        // Later the original token is restored before the actual Genie argument parsing.
        final String[] editedArgs = Util.mangleBareDoubleDash(args);
        return SpringApplication.exit(app.run(editedArgs));
    }
}

<MSG> Tweak message printed before the Agent starts up

Printing to UserConsole before the application context is initialized and the logging subsystem configured, results in the following issues:
1) It looks different from all other log messages
2) It pollutes stdout with a message that does not come from the underlying command. This breaks use cases such as:
  presto --execute '...' > output.txt

For these reasons, print directly to stderr instead.

<DFF> @@ -17,7 +17,6 @@
  */
 package com.netflix.genie;
 
-import com.netflix.genie.agent.cli.UserConsole;
 import com.netflix.genie.agent.cli.Util;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -53,7 +52,7 @@ public class GenieAgentApplication {
      * @param args command-line arguments
      */
     public static void main(final String[] args) {
-        UserConsole.getLogger().info("Starting Genie Agent");
+        System.err.println("Starting Genie Agent");
         System.exit(new GenieAgentApplication().run(args));
     }
 

{'addition_count': 1, 'commit_subject': 'Tweak message printed before the Agent starts up', 'deletion_count': 2, 'file_extension': '.java', 'lang': 'java', 'license': 'apache-2.0', 'repo_name': 'Netflix/genie'}