Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
seanf opened this issue May 23, 2017 · 2 comments
Closed

Comments

@seanf
Copy link

seanf commented May 23, 2017

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>
@seanf
Copy link
Author

seanf commented May 23, 2017

Correction: switching from getHostText to getHost would force users to upgrade to Guava 20+, not Guava 22.

@seanf seanf changed the title On Guava 22 RC1: NoSuchMethodError: com.google.common.net.HostAndPort.fromHost On Guava 22: NoSuchMethodError: com.google.common.net.HostAndPort.fromHost May 24, 2017
@jekh
Copy link
Collaborator

jekh commented Jul 16, 2017

Thanks for noting this. The issue has been resolved by #666.

It's unfortunate that guava still considers HostAndPort to be "beta". It's been in guava since 10.0 (Sept 2011). It's generally quite useful and I'd rather not use a roll-your-own solution, but it's unfortunate that they are so quick to remove functionality just because they technically haven't removed the "beta" designation after 6 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants