spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 351 forks source link

ArrayIndexOutOfBoundsException in UserProfileBuilder when name is empty String #240

Closed arminrosu closed 7 years ago

arminrosu commented 7 years ago

Summary

UserProfileBuilder throws an error when trying to create a profile with an empty string "" as a name.

Actual Behavior

java.lang.ArrayIndexOutOfBoundsException: 0

This error is caused by this line.

Expected Behavior

It should return a profile with an empty firstName and empty lastName, as it does when setting the name to null.

Configuration

Default

Version

Latest

Sample

UserProfile user = new UserProfileBuilder().setName("");
UserProfile user = UserProfileBuilder().setName(facebook.userOperations().getUserProfile().getName());
AndriyBrez commented 7 years ago

@arminrosu your bug doesn't reproduce. The code works as expected without any exceptions:

@Test
public void shouldReturnEmptyUserName() {
    UserProfileBuilder userProfileBuilder = new UserProfileBuilder().setName("");
    UserProfile user = userProfileBuilder.build();
    assertEquals("", user.getFirstName());
    assertNull(user.getLastName());
}
arminrosu commented 7 years ago

That seems right. Wondering how the error appeared. Closing for now as it seems to not apply. Thanks @AndriyBrez