Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MimeMessageHelper addInline with ByteArrayResource fail with null filename #33527

Closed
Assignees
bclozel
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug
Milestone
@blink38

Description

@blink38

Affects: spring-context-support-6.1.12


I'm creating a mail using MimeMessageHelper. I want to add inline file using ByteArrayResource.

The function used is :

publicvoidaddInline(StringcontentId,Resourceresource)throwsMessagingException {Assert.notNull(resource,"Resource must not be null");StringcontentType =getFileTypeMap().getContentType(resource.getFilename());addInline(contentId,resource,contentType);}

The problem is that org.springframework.core.io.ByteArrayResource extends org.springframework.core.io.AbstractResource which implements getFilename() returning null

/** * This implementation always returns {@code null}, * assuming that this resource type does not have a filename. */@Override@NullablepublicStringgetFilename() {returnnull;}

So

StringcontentType =getFileTypeMap().getContentType(resource.getFilename());

throw a java.lang.NullPointerException because jakarta.activation.MimetypesFileTypeMap.getContentType(String filename) code start with :

publicsynchronizedStringgetContentType(Stringfilename) {intdot_pos =filename.lastIndexOf(".");// period index

(jakarta.activation-api.2.1.3)

The thrown trace is

Caused by: java.lang.NullPointerException: Cannot invoke "String.lastIndexOf(String)" because "filename" is nullat jakarta.activation.MimetypesFileTypeMap.getContentType(MimetypesFileTypeMap.java:361)at org.springframework.mail.javamail.ConfigurableMimeFileTypeMap.getContentType(ConfigurableMimeFileTypeMap.java:180)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp