Skip to content

System.console() is null when using an IDE #5

@naverus

Description

@naverus

This error is triggered when trying to execute any logic by using any IDE(Idea, Eclipse, etc)

E.G. Execute UserInformation.java by using Idea/Eclipse and the following error will be triggered and no logic is being executed.

Caused by: java.lang.NullPointerException
	at com.convertapi.client.Http.getRequestBuilder(Http.java:62)
	at com.convertapi.client.Param.lambda$upload$1(Param.java:98)

Possible fix:


    static Request.Builder getRequestBuilder() {
        if (System.console() == null) {
            System.out.printf("VERSIJA: %s", Http.class.getPackage().getImplementationVersion());
        } else {
            System.console().printf("VERSIJA: %s", Http.class.getPackage().getImplementationVersion());
        }
        String agent = String.format("ConvertAPI-Java/%.1f (%s)", Http.class.getPackage().getImplementationVersion(), System.getProperty("os.name"));
        return new Request.Builder().header("User-Agent", agent);
    }

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