Skip to content

Commit

Permalink
#103 - Handle @nAmed with empty string / no actual string qualifier name
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed May 11, 2021
1 parent c937a61 commit b3988ed
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ boolean isExtraInjectionRequired() {

void buildAddFor(Append writer) {
writer.append(" if (builder.isAddBeanFor(");
if (name != null) {
if (name != null && !name.isEmpty()) {
writer.append("\"%s\", ", name);
}
writer.append(typeReader.getTypesRegister());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void buildAddFor(Append writer) {
if (isVoid) {
writer.append("Void.class");
} else {
if (name != null) {
if (name != null && !name.isEmpty()) {
writer.append("\"%s\", ", name);
}
if (typeReader != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.example.coffee.qualifier;

import jakarta.inject.Named;
import jakarta.inject.Singleton;

/**
* Named with empty string.
*/
@Named
@Singleton
public class FooQual {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.example.coffee.qualifier;

import io.avaje.inject.SystemContext;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class FooQualTest {

@Test
void test() {
FooQual bean = SystemContext.getBean(FooQual.class);
assertThat(bean).isNotNull();
}
}

0 comments on commit b3988ed

Please sign in to comment.