Skip to content

Commit

Permalink
[MASSEMBLY-964] Fix initFile for FileLocation, UrlLocation
Browse files Browse the repository at this point in the history
method FileLocation.initFile was private and can not be override in child class
  • Loading branch information
slawekjaranowski committed Jul 3, 2022
1 parent 8fba93d commit 7ab9293
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 10 deletions.
66 changes: 66 additions & 0 deletions src/it/projects/bugs/massembly-964/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.assembly.it</groupId>
<artifactId>massembly964</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>@project.version@</version>
<dependencies>
<dependency>
<groupId>org.apache.apache.resources</groupId>
<artifactId>apache-source-release-assembly-descriptor</artifactId>
<version>1.0.6</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>source-release-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
<descriptorRefs>
<descriptorRef>source-release</descriptorRef>
</descriptorRefs>
<tarLongFileMode>posix</tarLongFileMode>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
23 changes: 23 additions & 0 deletions src/it/projects/bugs/massembly-964/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

def sourceRelease = new File( basedir, "target/massembly964-0.0.1-SNAPSHOT-source-release.zip" )

assert sourceRelease.isFile()
assert sourceRelease.length() > 0
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FileLocation
this.specification = specification;
}

/** {@inheritDoc} */
@Override
public void close()
{
if ( ( channel != null ) && channel.isOpen() )
Expand Down Expand Up @@ -86,7 +86,7 @@ public void close()
}
}

/** {@inheritDoc} */
@Override
public File getFile()
throws IOException
{
Expand All @@ -107,7 +107,7 @@ File unsafeGetFile()
* initialize file.
* @throws IOException in case of error
*/
private void initFile()
protected void initFile()
throws IOException
{
if ( file == null )
Expand All @@ -129,13 +129,13 @@ protected void setFile( File file )
this.file = file;
}

/** {@inheritDoc} */
@Override
public String getSpecification()
{
return specification;
}

/** {@inheritDoc} */
@Override
public void open()
throws IOException
{
Expand All @@ -148,23 +148,23 @@ public void open()
}
}

/** {@inheritDoc} */
@Override
public int read( ByteBuffer buffer )
throws IOException
{
open();
return channel.read( buffer );
}

/** {@inheritDoc} */
@Override
public int read( byte[] buffer )
throws IOException
{
open();
return channel.read( ByteBuffer.wrap( buffer ) );
}

/** {@inheritDoc} */
@Override
public InputStream getInputStream()
throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class URLLocation
this.tempFileDeleteOnExit = tempFileDeleteOnExit;
}

/** {@inheritDoc} */
void initFile()
@Override
protected void initFile()
throws IOException
{
if ( unsafeGetFile() == null )
Expand Down

0 comments on commit 7ab9293

Please sign in to comment.