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

String Index Out of Bounds Error when compiling project with fieldgenerator #274

Closed
laszlo-amptech opened this issue Sep 21, 2022 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@laszlo-amptech
Copy link

laszlo-amptech commented Sep 21, 2022

annotationProcessor 'com.speedment.jpastreamer:fieldgenerator-standard:1.0.1'

When attempting to build the project, I get this error.

Execution failed for task ':compileJava'.

java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 148

I saw this with regard to the error, and have brought the development branch down that is supposed to have resolved this issue and used that build

#160

But am having this issue still.

@laszlo-amptech
Copy link
Author

So, I have discovered that the following annotations also cause this error ...

@NotNull(groups = { DatabaseGroup.class })
@NotNull(groups = { UiGroup.class, DatabaseGroup.class })
@notempty(groups = { UiGroup.class, DatabaseGroup.class })
@notempty(groups = { UiGroup.class, DatabaseGroup.class })
@notempty
@SiZe(max=50, groups={UiGroup.class, DatabaseGroup.class})

If I remove all of these, then the StringINdexOutOfBoundsException goes away. As I reintroduce these one by one, that error returns.

@laszlo-amptech
Copy link
Author

laszlo-amptech commented Sep 21, 2022

not sure why the above post messed with the capitalization but the notempty and the size ones should be Pascal case like the other two

@laszlo-amptech
Copy link
Author

So, once I removed these annotations, I was getting different errors. So, these entities also have some Helper methods that the Field Generator must be analyzing as well, and for some reason it sees two overloads that have the same method name as being the same.

Duplicate key setLocalDateValue (attempted merging values setLocalDateValue(java.lang.String,java.lang.String) and setLocalDateValue(java.lang.String,java.time.LocalDate))

When I removed the field-generator reference, the code builds/compiles just fine. I should think that field generator would ignore methods and look only for properties.

@laszlo-amptech
Copy link
Author

I will look around in the TypeParser to see what I can find in there. I'm assuming that's what is causing the error.

@julgus julgus added the bug Something isn't working label May 31, 2023
@julgus julgus self-assigned this May 31, 2023
@julgus
Copy link
Member

julgus commented Jun 5, 2023

Hi, I am so sorry for not paying attention to this any sooner. I understand you probably moved on to other tasks long ago but I'll try to follow up anyway.

I have attempted, but failed, to replicate this issue in the current version (3.0.1). My attempt is checked in as a branch on the JPAStreamer demo repository here: https://github.com/speedment/jpa-streamer-demo/tree/issue-274.

To summarize, I tried to replicate your examples by creating two groups; Group A and Group B. Annotating the Film.title and Film.length as follows:

@Entity
@Table(name = "film", schema = "sakila")
public class Film implements Serializable {
 
    ....

    @Column(name = "title", nullable = false, columnDefinition = "varchar(255)")
    @NotEmpty(message = "Title may not be empty", groups = {GroupA.class, GroupB.class})
    @NotNull(message = "Title may not be null", groups = {GroupA.class, GroupB.class})
    private String title;

    @Column(name = "length", columnDefinition = "smallint(5)")
    @NotEmpty(message = "Length may not be empty", groups = {GroupA.class, GroupB.class})
    @NotEmpty(message = "Length may not be empty", groups = {GroupA.class})
    @NotNull(message = "Length may not be null", groups = {GroupA.class, GroupB.class})
    @Size(min = 1, max = 300, message = "Length must be between 1 and 300 minutes characters long")
    private Integer length;

    ....

}

There are no compilation errors when running the fieldgenerator. Am I missing something?

@julgus
Copy link
Member

julgus commented Jun 19, 2023

Since I cannot reproduce this problem and haven't heard back from you I will close the issue. If you disagree with my decision, please reopen it.

@julgus julgus closed this as completed Jun 19, 2023
@julgus julgus added this to the 3.0.2 milestone Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants