Skip to content

On Guava 22: NoSuchMethodError: com.google.common.net.HostAndPort.fromHost #638

@seanf

Description

@seanf

This is like #398, except this time the method getHostText is missing because it is being removed from Guava. It's considered fair game because the class com.google.common.net.HostAndPort is marked @Beta. See https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis

This could be handled by switching from getHostText to getHost, but this would force users to upgrade to Guava 22 20 (and upgrading Guava is often difficult, precisely because of problems like this).

I would recommend avoiding Guava's @Beta classes/methods altogether (or perhaps Guava generally) in any library code, because they eventually lead to maintenance problems. Another option is to repackage the guava jar.

FindBugs with the extra detector GuavaBetaDetector can help to prevent @Beta API calls from creeping in again:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <configuration>
                    <plugins>
                        <plugin>
                            <groupId>com.overstock.findbugs</groupId>
                            <artifactId>library-detectors</artifactId>
                            <version>1.1</version>
                        </plugin>
                    </plugins>
                </configuration>
                <executions>
                    <execution>
                        <id>default</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions