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 range: -1 #10

Closed
natros opened this issue Sep 20, 2017 · 5 comments
Closed

String index out of range: -1 #10

natros opened this issue Sep 20, 2017 · 5 comments
Milestone

Comments

@natros
Copy link

natros commented Sep 20, 2017

String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1931)
	at org.mapstruct.intellij.util.MapstructUtil.getPropertyName(MapstructUtil.java:119)
	at org.mapstruct.intellij.util.MapstructUtil.getPropertyName(MapstructUtil.java:113)
	at org.mapstruct.intellij.search.MappingMethodUsagesSearcher.lambda$processQuery$0(MappingMethodUsagesSearcher.java:67)
	at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$0(DumbService.java:91)
	at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:119)
	at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:91)
	at org.mapstruct.intellij.search.MappingMethodUsagesSearcher.processQuery(MappingMethodUsagesSearcher.java:62)
	at org.mapstruct.intellij.search.MappingMethodUsagesSearcher.processQuery(MappingMethodUsagesSearcher.java:48)
	at com.intellij.openapi.application.QueryExecutorBase.execute(QueryExecutorBase.java:87)
	at com.intellij.util.ExecutorsQuery.processResults(ExecutorsQuery.java:45)
	at com.intellij.util.AbstractQuery.forEach(AbstractQuery.java:79)
	at com.intellij.util.MergeQuery.processSubQuery(MergeQuery.java:85)
	at com.intellij.util.MergeQuery.forEach(MergeQuery.java:57)
	at com.intellij.util.UniqueResultsQuery.process(UniqueResultsQuery.java:66)
	at com.intellij.util.UniqueResultsQuery.forEach(UniqueResultsQuery.java:56)
	at com.intellij.util.UniqueResultsQuery.findAll(UniqueResultsQuery.java:79)
	at com.intellij.find.findUsages.JavaFindUsagesHandler.findReferencesToHighlight(JavaFindUsagesHandler.java:273)
	at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.a(IdentifierHighlighterPass.java:163)
	at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.getHighlightUsages(IdentifierHighlighterPass.java:140)
	at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.a(IdentifierHighlighterPass.java:196)
	at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.doCollectInformation(IdentifierHighlighterPass.java:107)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:70)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.b(PassExecutorService.java:438)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1148)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.d(PassExecutorService.java:431)
	at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:548)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:493)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.c(PassExecutorService.java:430)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:406)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:142)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:237)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:404)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:165)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Version: 1.0.0
IntelliJ IDEA 2017.2.5
Build #IU-172.4343.5, built on September 19, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

@filiphr
Copy link
Member

filiphr commented Sep 20, 2017

Can you perhaps send me the @Mapping annotation where this occurs?

@filiphr filiphr added this to the 1.0.1 milestone Sep 20, 2017
@natros
Copy link
Author

natros commented Sep 21, 2017

I have a few mappers in my project but I'm not event touching them. It just happens.

But I can give you one of the mappers:

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import pt.ipb.creditacao.entities.IpbAlunos;
import pt.ipb.creditacao.shared.domain.Aluno;

@Mapper
public interface AlunosMapper {
  @Mapping(target = "bi", source = "biN")
  @Mapping(target = "codigoPostal", source = "codPostal")
  Aluno toAluno(IpbAlunos a);
}

@filiphr
Copy link
Member

filiphr commented Sep 21, 2017

@natros I found the issue. The issue happens if you have methods that are less than 3 characters. I have a fix ready, but will push it later today. I'll also publish 1.0.1 with this fix.

This has problems now:

public String so() {
    return null;
}

@natros
Copy link
Author

natros commented Sep 21, 2017

thanks

@filiphr
Copy link
Member

filiphr commented Sep 21, 2017

@natros the fix has been released. There should be an updated available as soon as it gets approved by Jetbrains.

Thanks a lot for the bug report.

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

No branches or pull requests

2 participants