2

While refactoring Rultor to use Cactoos instead of Guava, I’m having an issue with DockerRun class, in the envs method.

The current refactored result is:

final List<String> entries = new LinkedList<>();
for (final Entry<String, String> ent : extra.entrySet()) {
    entries.add(
        String.format(
          "%s=%s", ent.getKey(), ent.getValue()
        )
    );
}
return new Joined<>(
    DockerRun.envs(this.profile.read(), "/p/entry[@key='env']"),
    DockerRun.envs(this.node(), "entry[@key='env']"),
    new ListOf<>(entries)
);

When I build the project, the following warning message is thrown:

[WARNING] (...)rultor/src/main/java/com/rultor/agents/req/DockerRun.java:
[132,16] unchecked generic array creation for varargs 
parameter of type java.lang.Iterable<java.lang.String>[]

Note that line 132 in my case is the line of new Joined<>(

After searching SO I found similar issues, like this one, but no hints on how I can fix the warning message in my case.

So my question is, how can I still concatenate the iterables without getting the warning message, but still use Cactoos.

Filipe Freire
  • 823
  • 7
  • 21

1 Answers1

3

Try to write it this way:

new Joined<String>(
yegor256
  • 102,010
  • 123
  • 446
  • 597