Bug 41953 [Automatic Javadoc/Comment Formatting] Gives an NPE
When enabling the automatic formatting of Javadoc/comment sections (Preferences > Java > Work in Progress) the action "Source > Format" (Ctrl+Shift+F) fails with a null pointer exception. Reason: Call to "IDocument.getPartition(int)" in "org.eclipse.jdt.internal.ui.text.comment.CommentFormatter#format(String, int, int[], String) : String" returns "IDocument.DEFAULT_CONTENT_TYPE", for which no comment factory object is available. Fix: Correct fix is to use "IDocumentExtension3#getPartition(String, int)" with IJavaPartitions.JAVA_PARTITIONING to get the correct partition type.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/comment/CommentFormatter.java
/*****************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *****************************************************************************/
package org.eclipse.jdt.internal.ui.text.comment;
import org.eclipse.jdt.core.ICodeFormatter;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.ISourceViewer;
/**
 * Code formatter for general source code comments.
 * 
 * @since 3.0
 */
public class CommentFormatter implements ICodeFormatter {